smisy / aws-lambda-boilerplate

aws lambda, typescript, mongodb, nodejs
MIT License
6 stars 2 forks source link

AWS Lambda in TypeScript and MongoDB

serverless Build Status Codacy Badge Coverage Status

Features

Setup

npm install

Run unit tests

npm test

Build

npm run build

Start on local

npm start

Environment variable

serverless read env variables from env files. There 3 env files in project with 3 stages: local, development and production

env.local.yml
env.development.yml
env.production.yml

you should find the format file as below

env.local.yml
MONGODB_URL: mongodb://localhost:27017/aws-lambda
<variable name>: <value>
npm scripts env
npm start env.local.yml
npm run deploy env.development.yml
npm run deploy:prod env.production.yml

User Roles

You may have many roles in your project: user, moderator and admin. You may define your role policies in shared/Policies.ts

export default [
  {
    roles: ['user'],
    resources: '/users/profile',
    permissions: 'GET'
  }
];

Deploy to aws lambda services

We need aws credential to deploy our aws-lambda functions to aws services.

NOTE:

update your MONGODB_URI at env.development.yml and env.production.yml