Skip to content
/ smur Public template

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

License

Notifications You must be signed in to change notification settings

sagarpanchal/smur

Repository files navigation

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published