{"id":14967451,"url":"https://github.com/shavo007/serverless-nodejs-starter","last_synced_at":"2025-10-25T19:31:06.826Z","repository":{"id":31265575,"uuid":"127404028","full_name":"shavo007/serverless-nodejs-starter","owner":"shavo007","description":"A Node.js starter for the Serverless Framework with webpack, custom domain and unit test support","archived":false,"fork":false,"pushed_at":"2025-01-26T17:23:35.000Z","size":3049,"stargazers_count":10,"open_issues_count":12,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T10:11:39.064Z","etag":null,"topics":["aws","aws-apigateway","babel-webpack","circleci2","es6","eslint","express","lambda","mochajs","prettier","renovate","serverless-framework","serverless-nodejs-starter","webpack","yarn"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shavo007.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-30T08:38:14.000Z","updated_at":"2024-12-09T03:00:18.000Z","dependencies_parsed_at":"2023-11-22T18:38:37.096Z","dependency_job_id":"30d5f831-7636-4a77-a25c-6edd61eedf76","html_url":"https://github.com/shavo007/serverless-nodejs-starter","commit_stats":{"total_commits":901,"total_committers":6,"mean_commits":"150.16666666666666","dds":0.05882352941176472,"last_synced_commit":"321b9185b786301fdcf0e5ed07ad494a1dc52d3e"},"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shavo007%2Fserverless-nodejs-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shavo007%2Fserverless-nodejs-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shavo007%2Fserverless-nodejs-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shavo007%2Fserverless-nodejs-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shavo007","download_url":"https://codeload.github.com/shavo007/serverless-nodejs-starter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238201008,"owners_count":19433123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-apigateway","babel-webpack","circleci2","es6","eslint","express","lambda","mochajs","prettier","renovate","serverless-framework","serverless-nodejs-starter","webpack","yarn"],"created_at":"2024-09-24T13:38:04.736Z","updated_at":"2025-10-25T19:31:01.480Z","avatar_url":"https://github.com/shavo007.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serverless-nodejs-starter\n\n[![CircleCI](https://circleci.com/gh/shavo007/serverless-nodejs-starter.svg?style=svg\u0026circle-token=095ba73cea98fe5fb113431fee10d9350639145d)](https://circleci.com/gh/shavo007/serverless-nodejs-starter)\n\n[![Coverage Status](https://coveralls.io/repos/github/shavo007/serverless-nodejs-starter/badge.svg?branch=master)](https://coveralls.io/github/shavo007/serverless-nodejs-starter?branch=master)\n\nA Node.js starter for the Serverless Framework with webpack, custom domain and unit test support\n\nOnce installed, you can create and deploy functions with the latest ES6 features in minutes, with linting and formatting baked in.\n\n[![asciicast](https://asciinema.org/a/cuU1ADQApvbGbYN3VPJIsfJs0.png)](https://asciinema.org/a/cuU1ADQApvbGbYN3VPJIsfJs0?speed=3)\n\n[Serverless Node.js Starter](https://github.com/shavo007/serverless-nodejs-starter) uses the [serverless-webpack](https://github.com/serverless-heaven/serverless-webpack) plugin, [Babel](https://babeljs.io), and [Mocha](https://mochajs.org/). It supports:\n\n- **ES7 syntax in your handler functions**\n  - Use async/await\n  - And much more!\n- **Run API Gateway locally**\n  - Use `yarn serve`\n- **Support for unit tests**\n  - Run `yarn test:unit` to run your tests\n- **Sourcemaps for proper error messages**\n  - Error message show the correct line numbers\n  - Works in production with CloudWatch\n- **Automatic support for multiple handler files**\n  - No need to add a new entry to your `webpack.config.js`\n- **Add environment variables for your stages**\n\n\n\n## Install\n\n* Yarn\n\n1. `curl -o- -L https://yarnpkg.com/install.sh | bash`\n2. `yarn bash completion` - https://github.com/dsifford/yarn-completion\n\n\n\n```bash\n# If you don't already have the serverless cli installed, do that\nyarn global add serverless\n\n# Use the serverless cli to install this repo\nserverless install --url https://github.com/shavo007/serverless-nodejs-starter\n\n# cd into project and set it up\ncd serverless-nodejs-starter\n\n# The bootstrap command renames the project folder and project in package.json and serverless.yml\n# and initializes a git repo\nyarn bootstrap your-project-name\n\n# Install dependencies\nyarn install\n```\n\n## Development\n\nCreating and deploying a new function takes two steps, which you can see in action with this repo's default Hello World function (if you're already familiar with Serverless, you're probably familiar with these steps).\n\n#### 1. Add your function to `serverless.yml`\n\nIn the functions section of [`./serverless.yml`](./serverless.yml), you have to add your new function like so:\n\n```yaml\nfunctions:\n  hello:\n    handler: src/hello.default\n    events:\n          - http:\n              path: hello\n              method: get\n              cors: true\n```\n\nwe're setting up a function named `hello` with a handler at `src/hello.js` (the `.default` piece is just indicating that the function to run will be the default export from that file). The `http` event says that this function will run when an http event is triggered (on AWS, this happens via API Gateway).\n\n#### 2.a Create your vanilla function\n\nThis starter kit's Hello World function (which you will of course get rid of) can be found at [`./src/hello.js`](./src/hello.js). There you can see a basic function that's intended to work in conjunction with API Gateway (i.e., it is web-accessible). Like most Serverless functions, the `hello` function accepts an event, context, and callback. When your function is completed, you execute the callback with your response. (This is all basic Serverless; if you've never used it, be sure to read through [their docs](https://serverless.com/framework/docs/).\n\n#### 2.b Express wrapper function\n\nOn the other hand if you want to use express and proxy through api gateway have a look at [`./src/index.js`](./src/index.js)\n\nFor more info check out the tutorial at serverless and how it can help with cold starts [serverless blog](https://serverless.com/blog/serverless-express-rest-api/)\n\n\n#### 3. Create your custom domain\n\n```yaml\ncustomDomain:\n    domainName: shane.shanelee.xyz\n    certificateName: '*.shanelee.xyz'\n    basePath: ''\n    stage: ${self:provider.stage}\n    createRoute53Record: true\n    endpointType: 'regional'\n\n```\n\nTo create the custom domain\n\n**Make sure and change the values to suit your needs**\n\n`sls create_domain --stage dev`\n\n### Custom alerts\n\n\u003e A Serverless plugin to easily add CloudWatch alarms to functions\n\n```yaml\nalerts:\n  stages:\n    - dev\n  topics:\n    alarm:\n      topic: ${self:service}-${opt:stage}-alerts-alarm\n      notifications:\n        - protocol: email\n          endpoint: shanelee007@gmail.com # Change this to your email address\n```\n\nThis creates an SNS topic and triggers based on certain cloudwatch metrics and sends via email.\n\nFor more info check out [their docs](https://www.npmjs.com/package/serverless-plugin-aws-alerts)\n\n### API Gateway-like local dev server\n\nTo spin up a local dev server that will more closely match the API Gateway endpoint/experience:\n\n```bash\nyarn serve\n```\n\n### Adding new functions/files to Webpack\n\nWhen you add a new function to your serverless config, you don't need to also add it as a new entry\nfor Webpack. The `serverless-webpack` plugin allows us to follow a simple convention in our `serverless.yml`\nfile which is uses to automatically resolve your function handlers to the appropriate file:\n\n\n```yaml\nfunctions:\n  hello:\n    handler: src/hello.default\n```\n\nAs you can see, the path to the file with the function has to explicitly say where the handler\nfile is. (If your function weren't the default export of that file, you'd do something like:\n`src/hello.namedExport` instead.)\n\n### Renovate\n\n\u003e Automated Dependency Updates\n\nRenovate runs continuously to detect the latest available versions. And automagicaly creates PR on your github project with changelog and release notes.\n\nFor more info and how to authorise the github app check out [onboarding guide](https://renovateapp.com/docs/getting-started/configure-renovate)\n\n## Deploy\n\nAssuming you've already set up your default AWS credentials\n\n`yarn deploy:dev` will deploy to \"dev\" environment. You can deploy to `stage` or `production`\nwith:\n\n```bash\nyarn deploy:stage\n\n# -- or --\n\nyarn deploy:production\n```\n\nAfter you've deployed, the output of the deploy script will give you the API endpoint\nfor your deployed function(s), so you should be able to test the deployed API via that URL.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshavo007%2Fserverless-nodejs-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshavo007%2Fserverless-nodejs-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshavo007%2Fserverless-nodejs-starter/lists"}