Serverless shorten urls service using serverless framework.
$ git clone https://github.com/serverless-plus/shorten-urls.git
Install dependencies:
$ npm install
To start server locally, you can start local posgresql by docker and connect to it for development.
Start local docker postgresql:
$ npm run docker:up
Then copy .env.example
to .env
:
$ cp .env.example .env
Run server:
$ npm run dev
Before deployment, you should build project:
$ npm run build
Then 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:vpc
Then we can deploy database:
$ npm run deploy:db
For 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 --production
so we just deploy npm modules of production to layer,
$ npm run deploy:layer
Notice: 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 deploy
All git commit
mesage must follow below syntax:
type(scope?): subject #scope is optional
support 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