Skip to content
Serverless Template for NodeJS Typescript APIs
HTML TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
README.md
index.html
package.json
serverless.yml
tsconfig.json

README.md

NodeJS Typescript Serverless Template

Stack

  • NodeJS - JavaScript runtime built on Chrome's V8 JavaScript engine.
  • ExpressJS - Framework most commonly used to build APIs with NodeJS
  • Typescript - Provides us with a type structure for Javascript
  • Serverless Framework - Toolkit for building serverless applications .

Customization

Node.js changes:

  • Add the routes definitions in the src/routes.ts
  • Add the corresponding routes handling contollers as new .ts files

Serverless changes:

  • Update the service
  • Update the functions each mapping to the routes defined in the src/routes.ts

Pre-requisites

Setup Servlerless:

$ npm i -g serverless    

Set serverless credentials

$ serverless config credentials \ 
    --provider aws \ 
    --key xxxxxxxxxxxxxx \ 
    --secret xxxxxxxxxxxxxx

Create a serverless project/service

$ serverless create --template aws-nodejs --path <project folder name>

This template works with express, typescript and node hence the template is aws-nodejs

Local setup

To install dependencies of project.

$ cd <project folder name>
$ npm install

To generate files JS.

$ npm run build

Run project.

$ npm run start

Deployment

Deploy to AWS

$ npm run deploy

If you get a identity related error during deployment

$ export AWS_ACCESS_KEY_ID=<AWS_ACCESS_KEY_ID>
$ export AWS_SECRET_ACCESS_KEY=<AWS_SECRET_ACCESS_KEY>

License

MIT

Credit

You can’t perform that action at this time.