serverless-plus / shorten-urls

Serverless Shorten Urls Service

Home Page:https://url.sls.plus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shorten Urls

Online

Build Status semantic-release

Serverless shorten urls service using serverless framework.

Features

Usage

$ git clone https://github.com/serverless-plus/shorten-urls.git

Development

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

Deployment

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.

Deploy database

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

Deploy layer

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.

Deploy static files

Upload static files in public directory to COS:

$ npm run deploy:cos

Deploy server code

$ npm run deploy

Commit Lint

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.

License

MIT License

Copyright (c) 2020 Serverless Plus

About

Serverless Shorten Urls Service

https://url.sls.plus

License:MIT License


Languages

Language:TypeScript 44.6%Language:JavaScript 27.2%Language:Pug 17.8%Language:CSS 9.3%Language:Shell 1.2%