sagarpanchal / smur

A ExpressJS REST API server with Socket.io, Mongodb, Redis, and Yup built-in for headstart. Check README for more info.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Smur

github license code style: prettier

πŸš€ Getting Started

πŸ“‹ Prerequisites

  • node >=14.5.0
  • mongodb >= v4.2
  • redis-server >= v4.0.9 (for socket.io and caching)
    • wsl (only required on windows to run redis-server)

πŸ”§ Installing

Clone this repo

git clone <repo_url>

cd ./<project_directory>

Create and switch to directory to store keys

mkdir -p ./.keys && cd ./.keys

Generate RSA keys for JWT

On windows use git-bash or wsl

# Generate RSA256 certificate
ssh-keygen -t rsa -b 2048 -m PEM -f jwt_rsa.key

# Convert RSA256 public key to certificate
openssl rsa -in jwt_rsa.key -pubout -outform PEM -out jwt_rsa.key.pub

Go back to project root

cd ..

Install all dependencies

npm i

List of dependencies can be found in package.json

Configuration

For config, see Additional Configuration

Debugging

  • Debugging config for visual studio code is already included Press F5 to start debugging

Logging

  • By default, run-time exceptions will be logged to ./.logs/<NODE_ENV>/<YYYY>-<MM>/<YYYY>-<MM>-<DD>.json

To change logging to database see Additional Configuration

πŸ“¦ FrontEnd

  • Build and place your frontend files in /public directory
  • All HTTP GET requests not matching with ^\/api* will be redirected to /public/index.html

βš™οΈ Running

npm start          # runs `npm run dev`
npm run dev        # runs in development mode
npm run prod       # runs in production mode
npm run prod-stop  # stops in production mode
npm run prod-monit # `pm2 monit` in production

If you're using windows, please ensure that redis-server is running inside wsl before you run any of these commands > wsl sudo service redis-server restart

Production mode uses pm2 cluster-mode for load-balancing

See scripts in package.json

πŸ› οΈ Development

Testing

npm run test

Linting

npm run lint .

ESLint plugins for vscode

code --install-extension dbaeumer.vscode-eslint

About

A ExpressJS REST API server with Socket.io, Mongodb, Redis, and Yup built-in for headstart. Check README for more info.

License:MIT License


Languages

Language:JavaScript 97.2%Language:CSS 1.4%Language:Pug 1.3%Language:Shell 0.1%