Skip to content

aghontpi/watchlist-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d487c1a · Aug 15, 2021

History

33 Commits
Mar 10, 2021
Aug 15, 2021
Aug 15, 2021
Mar 6, 2021
Feb 8, 2021
Jul 5, 2021
Aug 15, 2021
Aug 11, 2021
Feb 8, 2021
Jun 13, 2021
Feb 8, 2021
Aug 11, 2021
Feb 8, 2021
Aug 11, 2021

Repository files navigation

watchlist - an express backend

One of the api for watchlist

build & test-cases

Folder structure

Name Description
src Source files of the server
src/public Static files to be used on client side
src/models Storing and retrieving datails from different schema, not using mongoose models
src/controllers Controllers define functions that respond to various http requests
src/server.ts Entry point for the app
src/util/ helpers - logging, cache, ratelimit, database
test Test cases to perform before taking a new build, is also used in combination with github actions before merging the code to master branch
views Template files for rendering dynamic content to client side, since this is a api server, there is not much there in this folder.
.env.example Project secrets, usernames, passwords, etc.
.github CI - github actions - run test cases on pull request and report if it is safe to merge.
.vscode vs-code workspace configuration, higly recommend using vs-code (install prettier es-lint plugin)
cache Cache folder for responses that do not need to connect to database all the time.

Manual

install nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

update node to latest version

nvm install node

instal redis

yum install redis

systemctl enable redis

vim /etc/redis.conf
# change bind-address, password

systemctl start redis

redis-cli

install nginx

apt or yum install nginx

install yarn

npm install yarn --g

build

yarn build

test

yarn test

deploy to production

yarn add pm2 -G

yarn pm2 start build/server.js

configure nginx

  • location
  • ssl
  • proxy

Built with

  • typescript
  • express
  • jwt
  • jest
  • supertest
  • handlebars
  • node
  • pm2
  • mongodb
  • redis
  • nginx
  • github actions

preferred mongoclient-native-driver for perfomance over mongoose odm.