A boilerplate/starter project for quickly building RESTful APIs using Node.js, Express, and Postgres SQL.
By running following command, you will get a Node.js app installed and fully configured on your machine. The app comes with many built-in features, such as authentication using JWT , Forgot and Reset Password etc. For more details, check the features list below.
If you want to do the installation , follow these steps:
Clone the repo:
git clone URL
Install the dependencies:
npm install
Set the environment variables:
# open .env and modify the environment variables (if needed)
npm run sync:db
npm run seed:db
npm start
- Authentication and authorization: using passport
- Error handling: centralized error handling mechanism
- Process management: advanced production process management using PM2
- Environment variables: using dotenv
- CORS: Cross-Origin Resource-Sharing enabled using cors
Running locally:
npm start
Running in production:
npm run prod
The environment variables can be found and modified in the .env
file. They come with these default values:
# Port number
PORT=8000
# URL of the Postgres DB
DB_HOST=localhost
# JWT
# JWT secret key
JWT_SECRET=smart-key
# SMTP configuration options for the email service
# For testing, you can use a fake SMTP service like Ethereal: https://ethereal.email/create
SMTP_HOST=email-server
SMTP_PORT=587
SMTP_USERNAME=email-server-username
SMTP_PASSWORD=email-server-password
[email protected]
src\
|--config\ # Environment variables and configuration related things
|--controllers\ # Route controllers (controller layer)
|--middlewares\ # Custom express middlewares
|--models\ # {Postgres} models (data layer)
|--routes\ # Routes
|--utils\ # Utility classes and functions
|--app.js # Express app
|--bin
|--www # App entry point
List of available routes: