-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add env and offline support (#19) * Adding more comments on env.yml * Updating serverless-offline * Formatting comments * Update README.md
- Loading branch information
Showing
6 changed files
with
632 additions
and
2 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 |
---|---|---|
|
@@ -43,3 +43,6 @@ Session.vim | |
# Serverless | ||
.webpack | ||
.serverless | ||
|
||
#env | ||
env.yml |
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 |
---|---|---|
@@ -1,19 +1,22 @@ | ||
# Serverless Node.js Starter | ||
|
||
A Serverless starter that adds ES7 async/await and unit test support. Part of the [Serverless Stack](http://serverless-stack.com) guide. | ||
A Serverless starter that adds ES7 async/await, serverless-offline, environment variables, and unit test support. Part of the [Serverless Stack](http://serverless-stack.com) guide. | ||
|
||
[Serverless Node.js Starter](https://github.com/AnomalyInnovations/serverless-nodejs-starter) uses the [serverless-webpack](https://github.com/serverless-heaven/serverless-webpack) plugin, [Babel](https://babeljs.io), and [Jest](https://facebook.github.io/jest/). It supports: | ||
|
||
- **ES7 syntax in your handler functions** | ||
- Use async/await | ||
- And much more! | ||
- **Run API Gateway locally** | ||
- Use `serverless offline start` | ||
- **Support for unit tests** | ||
- Run `npm test` to run your tests | ||
- **Sourcemaps for proper error messages** | ||
- Error message show the correct line numbers | ||
- Works in production with CloudWatch | ||
- **Automatic support for multiple handler files** | ||
- No need to add a new entry to your `webpack.config.js` | ||
- **Add environment variables for your stages** | ||
|
||
If you'd like to learn how to setup your existing Serverless project to support ES7 async/await, use this [guide on Serverless-Stack.com](http://serverless-stack.com/chapters/add-support-for-es6-javascript.html). | ||
|
||
|
@@ -84,6 +87,12 @@ To run a function on your local | |
$ serverless invoke local --function hello | ||
``` | ||
|
||
To simulate API Gateway locally using [serverless-offline](https://github.com/dherault/serverless-offline) | ||
|
||
``` bash | ||
$ serverless offline start | ||
``` | ||
|
||
Run your tests | ||
|
||
``` bash | ||
|
@@ -106,6 +115,13 @@ $ serverless deploy function --function hello | |
|
||
To add another function as a new file to your project, simply add the new file and add the reference to `serverless.yml`. The `webpack.config.js` automatically handles functions in different files. | ||
|
||
To add environment variables to your project | ||
|
||
1. Rename `env.example` to `env.yml`. | ||
2. Add environment variables for the various stages to `env.yml`. | ||
3. Uncomment `environment: ${file(env.yml):${self:provider.stage}}` in the `serverless.yml`. | ||
4. Make sure to not commit your `env.yml`. | ||
|
||
### Support | ||
|
||
- Send us an [email](mailto:[email protected]) if you have any questions | ||
|
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 |
Oops, something went wrong.