Skip to content

[pull] master from claudiajs:master #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e4e8729
issue template
gojko Feb 18, 2017
9434c0d
iot example
gojko Feb 19, 2017
41edec8
more info on iot topics
gojko Feb 19, 2017
2638cae
ensure correct version
gojko Feb 20, 2017
aa291e6
Add tutorial on creating a webhook with Twilio and Shippo
mootrichard Mar 15, 2017
79cb86a
Merge pull request #19 from mootrichard/add-twilio-shippo-tutorial
gojko Mar 16, 2017
c552ab3
Merge pull request #1 from claudiajs/master
mootrichard Mar 16, 2017
615f985
Update Readme with link to Twilio-Shippo example
mootrichard Mar 16, 2017
ff79cb9
Merge pull request #20 from mootrichard/master
gojko Mar 16, 2017
cfa01df
Fix link to example
mootrichard Mar 16, 2017
ca68535
Merge pull request #21 from mootrichard/master
gojko Mar 16, 2017
2bc1dfe
Fix broken Markdown headings
bryant1410 Apr 17, 2017
8f75c1d
Merge pull request #22 from bryant1410/master
stojanovic Apr 17, 2017
97cf41e
example for fastify
adrai Jul 5, 2017
24c47a4
Merge pull request #23 from adrai/master
gojko Jul 6, 2017
fd0767a
get example codebase working with claudiajs
SgtPooki Aug 24, 2017
d1fff3a
fix mention of project
SgtPooki Aug 24, 2017
24b1bf4
Merge pull request #24 from SgtPooki/master
gojko Aug 24, 2017
e8a23f6
adding Stripe Checkout payment serverless function example
simalexan Dec 5, 2017
2c8268a
minor addition to the title box
simalexan Dec 5, 2017
57e3597
Merge pull request #26 from claudiajs/feat/stripe-checkout-payment-cl…
simalexan Dec 5, 2017
782e316
minor fixes for the stripe-checkout-payment
simalexan Dec 6, 2017
6eb103a
update all examples to use v3
gojko Jan 4, 2018
22446bc
cors example
gojko Mar 18, 2018
5d3eee3
removed build dir
gojko Mar 18, 2018
cfeaba5
bump all examples to v4
gojko Apr 9, 2018
83833da
using new pandoc binary
gojko May 24, 2018
bcf57c3
claudia pack example
gojko Jun 7, 2018
fd69a5b
link to sam pack
gojko Jun 7, 2018
b44b78f
Update README.md
gojko Jun 25, 2018
d6d0e87
Update README.md
gojko Jul 8, 2018
e2e928f
using superb 3.0 syntax
gojko Jul 23, 2018
fe3d1a6
bump claudia version
gojko Oct 13, 2018
22464ba
replacing rsvg binary with lambda layer
simalexan Dec 27, 2018
d360458
adding Pandoc Lambda Layer
simalexan Dec 27, 2018
02938da
update fastify example
adrai Apr 1, 2019
fcc4433
Merge pull request #33 from adrai/master
gojko Apr 2, 2019
b3cbee3
use normalized headers
gojko May 10, 2019
7f6c4d0
Merge branch 'master' of github.com:claudiajs/example-projects
gojko May 10, 2019
0d649df
update fastify example
adrai Jul 15, 2019
0859f8e
Merge pull request #34 from adrai/master
gojko Jul 15, 2019
1e6a990
update fastify deps
adrai Jul 26, 2019
0379c51
Merge pull request #35 from adrai/patch-1
gojko Jul 26, 2019
1cba2f7
Adding example for deployment of a Private API gateway to AWS.
Jul 26, 2019
1ac3578
Merge pull request #36 from shortstacked/master
gojko Jul 27, 2019
32d07be
Update README.md
gojko Sep 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "crockford",
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"semi": ["error", "always"],
"strict": ["error", "function"],
"no-unused-vars": "error",
"indent": ["error", "tab" ],
"no-const-assign": "error",
"one-var": "error",
"prefer-const": "error",
"no-var": "warn",
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
"quotes": ["error", "single", {"avoidEscape": true, "allowTemplateLiterals": true}]
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/package-lock.json
**/claudia*.json
**/node_modules
**/npm-debug.log
Expand Down
16 changes: 16 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Use the [Claudia.js Gitter Chat](https://gitter.im/claudiajs/claudia) instead to ask a general question or request assistance/support.

Please use GitHub issues only to report bugs with example projects. To report a bug or a problem, please fill in the sections below. The more you provide, the better we'll be able to help.

---

* Expected behaviour:

* What actually happens:

* Link to a minimal, executable project that demonstrates the problem:

* Steps to install the project:

* Steps to reproduce the problem:

18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Claudia.js Example projects
# Claudia.js Example projects

<img src="https://claudiajs.github.io/claudiajs.com/assets/claudiajs.svg" height="300" align="right" />
<img src="https://claudiajs.com/assets/claudia-logo-letters-500.png" height="300" align="right" />


## Hello world
Expand All @@ -11,14 +11,14 @@
## Common Development tasks

* [Using NPM Modules](using-npm-modules) &ndash; a slightly more complex function, shows how to deploy third party dependencies using Claudia.js
* [Using Babel](babel) &ndash; shows how to deploy transpiled Babel code
* [Using Babel](babel) &ndash; shows how to deploy transpiled Babel code
* [Environment Variables](env-variables) &ndash; setting and using Lambda environment variables
* [Detecting Context](detecting-context) &ndash; detect if a function was called for development or production, in order to load the right configuration
* [Recursive invocation](recursive-invoke) &ndash; an example of how Lambda can asynchronously call itself to work around timing limitations
* [Packing for AWS SAM](sam-packaging) &ndash; an example of how to use Claudia to prepare packages for deployment using CloudFormation and AWS SAM

## Web API


* [Web Serving HTML](web-serving-html) &ndash; shows how to change error and success content types and response codes, and how to perform browser redirects
* [Generic handlers](web-api-generic-handlers) &ndash; shows how to capture dynamic paths and set up handlers for any content type easily
* [Custom response codes](web-api-custom-status-code) &ndash; shows how to change status codes for response
Expand All @@ -35,10 +35,12 @@
* [Custom Authorizers](custom-authorizers) &ndash; a simple example of how to set up custom authorizers in API Gateway
* [Geo location](api-gw-geolocation) &ndash; shows how to retrieve the country where your users originated the request
* [Binary Content](binary-content) &ndash; shows how to configure API Gateway to send or receive binary data
* [Twilio & Shippo webhook](twilio-shippo-webhook) &ndash; shows how to create an API endpoint for processing webhook updates using Twilio and Shippo

## Event processing

* [S3 File Processing](s3-file-processing) &ndash; an example service that converts files uploaded to S3; shows how to wire up Lambda to respond to S3 events
* [IOT Topic Filters](iot-topic-filter) &ndash; an example how to trigger a function when a message is posted to an IOT Data Topic
* [Pandoc S3 Converter](pandoc-s3-converter) &ndash; a more complex example that converts S3 files to .docx using Pandoc
* [SVG to PDF S3 Converter](svg-to-pdf-s3-converter) &ndash; convert SVG files uploaded to S3 to PDF format using RSVG and Cairo
* [Website Email Alert](website-email-alert) &ndash; periodically check a URL and send an e-mail if it is not available; shows how to send e-mails using SES and set up Lambda functions as scheduled recurring events
Expand All @@ -47,14 +49,15 @@

* [Deploying a Proxy API](deploy-proxy-api) &ndash; an example of how to create an API Gateway that will proxy all requests directly to a Lambda function
* [Running Express Apps in AWS Lambda](express-app-lambda) &ndash; an example of how to deploy an existing Express app with minimal changes to Lambda
* [Running fastify Apps in AWS Lambda](fastify-app-lambda) &ndash; an example of how to deploy an existing fastify app with minimal changes to Lambda

## Chat-bots

* [Simple Bot](simple-bot) &ndash; an example demonstrating how to receive and respond with simple text messages
* [Facebook Messenger Bot with Buttons](bot-with-buttons) &ndash; an example showing how to create more complex platform specific messages, for example Facebook buttons
* [Space Explorer Bot](https://github.com/stojanovic/space-explorer-bot) &ndash; uses NASA's API to get the data and images about the space, shows how to use Facebook Template builders for response messages.
* [Slack Delayed Reply](slack-delayed-response) &ndash; an example showing how to send delayed and multiple replies for Slack slash commands.
* [Alexa Skill](alexa-skill) &ndash; an Amazon Echo (Alexa) skill sample that spells out English words
* [Alexa Skill](alexa-skill) &ndash; an Amazon Echo (Alexa) skill sample that spells out English words

## Examples in other repositories

Expand All @@ -71,4 +74,7 @@ For more information on the Web API configuration syntax, check out the [Claudia

## Prerequisites

AWS Lambda currently runs Node.js version 4.3.2 (optionally, you can downgrade to 0.10.36 by using `--runtime` when [creating the function](https://github.com/claudiajs/claudia/blob/master/docs/create.md)). It's best to use that version for testing. To get started, make sure your credentials are configured. See the [ClaudiaJS Getting Started Guide](https://github.com/claudiajs/claudia/blob/master/getting_started.md) for more information.
To get started, make sure your credentials are configured. See the [ClaudiaJS Getting Started Guide](https://github.com/claudiajs/claudia/blob/master/getting_started.md) for more information.

AWS Lambda currently runs Node.js version 10 and 8 (you can choose the runtime with `--runtime` when [creating the function](https://github.com/claudiajs/claudia/blob/master/docs/create.md)). It's best to use the same version for testing and deployment.

5 changes: 4 additions & 1 deletion alexa-skill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"author": "Slobodan Stojanovic <[email protected]> (http://slobodan.me/)",
"license": "MIT",
"dependencies": {
"claudia-bot-builder": "^2.7.1"
"claudia-bot-builder": "^4"
},
"devDependencies": {
"claudia": "^4"
}
}
4 changes: 2 additions & 2 deletions api-gw-geolocation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"author": "",
"license": "MIT",
"dependencies": {
"claudia-api-builder": "^2.3.1"
"claudia-api-builder": "^4"
},
"devDependencies": {
"claudia": "^2.5.0"
"claudia": "^4"
}
}
4 changes: 2 additions & 2 deletions async-await-and-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
},
"license": "MIT",
"dependencies": {
"claudia-api-builder": "^2.3.1",
"claudia-api-builder": "^4",
"node-fetch": "^1.6.3"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-plugin-async-to-promises": "^1.0.5",
"babel-preset-es2015": "^6.18.0",
"claudia": "^2.5.0"
"claudia": "^4"
}
}
4 changes: 2 additions & 2 deletions aws-mobile-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"license": "MIT",
"dependencies": {
"aws-sdk": "^2.4.3",
"claudia-api-builder": "^1.3.0",
"claudia-api-builder": "^4",
"denodeify": "^1.2.1"
},
"devDependencies": {
"claudia": "^1.4.2"
"claudia": "^4"
}
}
4 changes: 2 additions & 2 deletions babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
},
"license": "MIT",
"dependencies": {
"claudia-api-builder": "^2.3.1"
"claudia-api-builder": "^4"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"claudia": "^2.5.0"
"claudia": "^4"
}
}
4 changes: 2 additions & 2 deletions binary-content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"author": "Gojko Adzic <[email protected]>",
"license": "MIT",
"devDependencies": {
"claudia": "^2.6.0"
"claudia": "^4"
},
"dependencies": {
"claudia-api-builder": "^2.4.0"
"claudia-api-builder": "^4"
}
}
4 changes: 2 additions & 2 deletions bot-with-buttons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
},
"license": "MIT",
"dependencies": {
"claudia-bot-builder": "^1.1.0",
"claudia-bot-builder": "^4",
"wikidata-search": "^1.0.3"
},
"devDependencies": {
"claudia": "^1.4.1"
"claudia": "^4"
}
}
1 change: 1 addition & 0 deletions cors-settings/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
18 changes: 18 additions & 0 deletions cors-settings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# cors test example

## set up

0. run `npm i` to get the deps
1. (optional) change the region in the `package.json` config section
2. run `npm run create` to deploy a test lambda
3. run `npm run serve` to run the web site on port 8080
4. open http://localhost:8080 -- fill in some data into the form and submit

## change the test

* change the lambda code in `api.js` and run `npm run update` to redeploy
* change the web site code in `web.js` and re-run `npm run serve` to recompile the javascript

## clean up after test

* `npm run destroy` to remove the API
11 changes: 11 additions & 0 deletions cors-settings/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const Api = require('claudia-api-builder'),
api = new Api();

api.post('/registrants', function (request) {
return request.body;
});

api.corsMaxAge(60);
api.corsOrigin('http://localhost:8080')

module.exports = api;
18 changes: 18 additions & 0 deletions cors-settings/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html>

<body>
<form id="corsform">
<label>Request type:</label>
<label>XHR <input type="radio" name="rtype" value="xhr" checked /></label>
<label>Fetch <input type="radio" name="rtype" value="fetch" /></label>
<br>
<input type="text" name="firstname" placeholder="first name"/>
<input type="text" name="lastname" placeholder="last name"/>
</br/>
<input type="submit" value="submit" />
<hr/>
<textarea id="result"></textarea>
</form>
<script src="build/main.js"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions cors-settings/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "test-cors",
"version": "1.0.0",
"scripts": {
"create": "claudia create --api-module api --region $npm_package_config_awsRegion",
"update": "claudia update",
"serve": "webpack && http-server -c-1",
"destroy": "claudia destroy"
},
"config": {
"awsRegion": "us-east-1"
},
"files": [
"api.js"
],
"devDependencies": {
"claudia": "^4",
"http-server": "^0.11.1",
"webpack": "^3.10.0"
},
"dependencies": {
"claudia-api-builder": "^4"
}
}
58 changes: 58 additions & 0 deletions cors-settings/web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const claudiaConfig = require('./claudia.json'),
region = require('./package.json').config.awsRegion,
url = `https://${claudiaConfig.api.id}.execute-api.${region}.amazonaws.com/latest`,
sendFetchRequest = function (endpoint, content) {
const headers = new Headers({
'Content-Type': 'application/json'
}),
requestParams = {
method: 'POST',
headers: headers,
mode: 'cors',
body: JSON.stringify(content)
};
console.log('sending fetch request');
return fetch(`${url}/${endpoint}`, requestParams).then(response => response.text());
},
sendXHRRequest = function (endpoint, content) {
console.log('sending xhr request');
return new Promise((resolve, reject) => {
const oReq = new XMLHttpRequest();
oReq.addEventListener('load', function () {
resolve(this.responseText);
});
oReq.addEventListener('error', reject);
oReq.addEventListener('abort', reject);
oReq.open('POST', `${url}/${endpoint}`);
oReq.setRequestHeader('Content-Type', 'application/json');
oReq.send(JSON.stringify(content));
});
};

document.addEventListener('DOMContentLoaded', () => {
document.querySelector('#corsform').addEventListener('submit', e => {
e.preventDefault();
try {
const form = e.target,
inputFields = Array.from(form.querySelectorAll('input[type=text]')),
resultField = form.querySelector('textarea'),
requestTypeXhr = form.querySelector('input[type=radio][value=xhr]'),
requestMethod = (requestTypeXhr.checked) ? sendXHRRequest: sendFetchRequest,
content = {};
inputFields.forEach(field => {
content[field.getAttribute('name')] = field.value;
});
requestMethod('registrants', content)
.then(respText => {
resultField.value = respText || 'empty response';
}).catch(e => {
console.error('received error', e);
resultField.value = e.message || e;
});
} catch (e) {
console.error('error submitting request', e);
}
});
});


9 changes: 9 additions & 0 deletions cors-settings/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*global require, module, __dirname, process, console */
const path = require('path');
module.exports = {
entry: { 'main': path.resolve(__dirname, 'web.js') },
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].js'
}
};
4 changes: 2 additions & 2 deletions custom-authorizers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"author": "",
"license": "MIT",
"dependencies": {
"claudia-api-builder": "^1.6.0"
"claudia-api-builder": "^4"
},
"devDependencies": {
"claudia": "^1.7.0"
"claudia": "^4"
}
}
2 changes: 1 addition & 1 deletion deploy-proxy-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "Gojko Adzic <[email protected]>",
"license": "MIT",
"devDependencies": {
"claudia": "^2.0.1"
"claudia": "^4"
}
}
2 changes: 1 addition & 1 deletion detecting-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"call-production": "claudia test-lambda --version production"
},
"devDependencies": {
"claudia": "^1.2.3"
"claudia": "^4"
}
}
4 changes: 2 additions & 2 deletions dynamodb-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
},
"dependencies": {
"aws-sdk": "^2.4.11",
"claudia-api-builder": "^1.5.0"
"claudia-api-builder": "^4"
},
"devDependencies": {
"claudia": "^1.5.0"
"claudia": "^4"
}
}
2 changes: 1 addition & 1 deletion env-variables/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
},
"license": "MIT",
"devDependencies": {
"claudia": "^2.2.0"
"claudia": "^4"
}
}
Loading