-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5dc8b19
Showing
11 changed files
with
9,810 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"plugins": ["source-map-support", "transform-runtime"], | ||
"presets": [ | ||
["env", { "node": "8.10" }], | ||
"stage-3" | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# vim | ||
.*.sw* | ||
Session.vim | ||
|
||
# Serverless | ||
.webpack | ||
.serverless | ||
|
||
# env | ||
env.yml | ||
.env | ||
|
||
# Jetbrains IDEs | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Anomaly Innovations | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Serverless Stack Demo API | ||
|
||
[Serverless Stack](http://serverless-stack.com) is a free comprehensive guide to creating full-stack serverless applications. We create a [note taking app](http://demo.serverless-stack.com) from scratch. | ||
|
||
This repo is for the serverless backend API that we build over the course of the tutorial. You can find the repo for the frontend React app [here](https://github.com/AnomalyInnovations/serverless-stack-demo-client). And the repo for the tutorial [here](https://github.com/AnomalyInnovations/serverless-stack-com). | ||
|
||
#### Steps | ||
|
||
To support the different chapters and steps of the tutorial; we use branches to represent the project codebase at the various points. Here is an index of the various chapters and branches in order. | ||
|
||
- [Set up the Serverless Framework](../../tree/setup-the-serverless-framework) | ||
- [Add Support for ES6/ES7 JavaScript](../../tree/add-support-for-es6-es7-javascript) | ||
- [Add a Create Note API](../../tree/add-a-create-note-api) | ||
- [Add a Get Note API](../../tree/add-a-get-note-api) | ||
- [Add a List All the Notes API](../../tree/add-a-list-all-the-notes-api) | ||
- [Add an Update Note API](../../tree/add-an-update-note-api) | ||
- [Add a Delete Note API](../../tree/add-a-delete-note-api) | ||
|
||
#### Usage | ||
|
||
To use this repo locally you need to have the [Serverless framework](https://serverless.com) installed. | ||
|
||
``` bash | ||
$ npm install serverless -g | ||
``` | ||
|
||
Clone this repo and install the NPM packages. | ||
|
||
``` bash | ||
$ git clone https://github.com/AnomalyInnovations/serverless-stack-demo-api | ||
$ npm install | ||
``` | ||
|
||
Run a single API on local. | ||
|
||
``` bash | ||
$ serverless invoke local --function list --path event.json | ||
``` | ||
|
||
Where, `event.json` contains the request event info and looks something like this. | ||
|
||
``` json | ||
{ | ||
"requestContext": { | ||
"authorizer": { | ||
"claims": { | ||
"sub": "USER-SUB-1234" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Finally, run this to deploy to your AWS account. | ||
|
||
``` bash | ||
$ serverless deploy | ||
``` | ||
|
||
#### Maintainers | ||
|
||
Serverless Stack is authored and maintained by Frank Wang ([@fanjiewang](https://twitter.com/fanjiewang)) & Jay V ([@jayair](https://twitter.com/jayair)). [**Subscribe to our newsletter**](http://eepurl.com/cEaBlf) for updates on Serverless Stack. Send us an [email][Email] if you have any questions. | ||
|
||
[Email]: mailto:[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# HOW TO USE: | ||
# | ||
# 1 Add environment variables for the various stages here | ||
# 2 Rename this file to env.yml and uncomment it's usage | ||
# in the serverless.yml. | ||
# 3 Make sure to not commit this file. | ||
|
||
dev: | ||
APP_NAME: serverless-nodejs-starter | ||
|
||
prod: | ||
APP_NAME: serverless-nodejs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const hello = async (event, context, callback) => { | ||
const response = { | ||
statusCode: 200, | ||
body: JSON.stringify({ | ||
message: `Go Serverless v1.0! ${(await message({ time: 1, copy: 'Your function executed successfully!'}))}`, | ||
}), | ||
}; | ||
|
||
callback(null, response); | ||
}; | ||
|
||
const message = ({ time, ...rest }) => new Promise((resolve, reject) => | ||
setTimeout(() => { | ||
resolve(`${rest.copy} (with a delay)`); | ||
}, time * 1000) | ||
); |
Oops, something went wrong.