Serverless shorten urls service using serverless framework.
$ git clone https://github.com/serverless-plus/shorten-urls.gitInstall dependencies:
$ npm installTo start server locally, you can start local posgresql by docker and connect to it for development.
Start local docker postgresql:
$ npm run docker:upThen copy .env.example to .env:
$ cp .env.example .envRun server:
$ npm run devBefore deployment, you should build project:
$ npm run buildThen you can deploy relative resources, after the first deployment, below step is optional for next time.
Serverless PostgreSQL need VPC, so we need create a VPC for it:
$ npm run deploy:vpcThen we can deploy database:
$ npm run deploy:dbFor nodejs project, we can deploy node_modules directory to layer, so after first deployment, we do not need to deploy node_modules directory again, this is very useful to make our source code deployment quickly.
To make layer code smaller, we can run:
$ rm -rf node_modules && npm install --productionso we just deploy npm modules of production to layer,
$ npm run deploy:layerNotice: after layer deployment, if you do not change npm modules for production, you don't need to deploy layer.
Upload static files in public directory to COS:
$ npm run deploy:cos$ npm run deployAll git commit mesage must follow below syntax:
type(scope?): subject #scope is optionalsupport type:
- feat: add new feature
- fix: fix bug or patch feature
- ci: CI
- chore: modify config, nothing to do with production code
- docs: create or modifiy documents
- refactor: refactor project
- revert: revert
- test: test
Most of time, we just use feat and fix.
MIT License
Copyright (c) 2020 Serverless Plus