/wd301-api

API used in WD301 course.

Primary LanguageJavaScript

wd301-api

API server for WD301

steps to run locally

npm install
npm start

Running in production

  • Install pm2
npm install pm2 -g
  • Add environment variables to .env file (Refer .env.sample file)
DATABASE_URL="postgres://postgres:postgres@localhost:5432/wd301_db"
PORT=8081
JWT_SECRET="your_jwt_secret"
SALT_ROUNDS=10
  • Make sure the database exists
cd wd301-api
NODE_ENV=production npx sequelize-cli db:create
  • Run the application
cd wd301-api
NODE_ENV=production pm2 start "npx sequelize-cli db:migrate && npm start" --name wd301-api
  • Stopping the application
pm2 stop wd301-api
  • You can get the logs for the application by running
pm2 logs

HTTPS support

You can use Nginx or any other reverse proxy to terminate any SSL connections.