serverless-nodejs-starter-template
A boilerplate for new Serverless Nodejs projects with tests and basic configurations
Description
Simple hello function take name and return with hello
const hello = require('./lib/hello');
const response = require('./lib/response');
const helloFn = async (event) => {
let body = event.body ? JSON.parse(event.body) : event; //api gateway (event.body) vs invoke (event)
let result = hello(body);
return response(result);
}
module.exports.hello = helloFnfeatures
- Ready to use default configuration for serverless framework
- Environment variables ready with develop, staging and production
- Works with both invoke and api
- Serverless offline to test the api gateway localy
Installation
-
Install & Configure serverless framework, Guide here
-
Clone this repo and run
npm installthennpm run config
Test locally
npm run localwill run the function directly without serverless framework for fast test on your local machinenpm run invokewill invoke the function locally and pass the data intest-data.jsonto your function as bodynpm run apiwill run api gateway locally in your machine on port3000so you can test the function as it on AWS api gateway
Deploy
npm run deploywill deploy on production and load your .env.production environment variablesnpm run deploy-developwill deploy on develop and load your .env.production environment variablesnpm run deploy-stagingwill deploy on staging and load your .env.production environment variables
Contribution
Feel free to fork, commit and submit pull request if you find a bug, or you want to add support to a new environment. Contributions are very welcome.
License
MIT

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
