/Express-JWT-Sequelize-Boilerplate

:seedling: Express.js backend boilerplate

Primary LanguageTypeScriptMIT LicenseMIT

Express.js Backend Boilerplate

Node.js npm Express.js Sequelize

Features

  • TypeScript configured
  • JWT based authentication and middleware
  • User signup and login
  • Sequelize ORM for database interaction

Available Scripts

In the project directory, you can run:

npm start

Runs the server in development mode. Open http://localhost:8000 to in your browser, you will see Express.js server is running!.

npm run start:dev

Runs the server in development mode with hotload. Hotload configured by nodemon

npm run build

Builds the app for production to the dist folder.

npm run serve:dev, npm run serve:prod

After build the project, Runs the development/production server. Entry file is dist/index.js.

Project Structure

root
|
|- dist/
|
|- node_modules/
|
|- src/
|  |- config/
|  |  |- database.ts
|  |
|  |- controller/
|  |  |- auth.controller.ts
|  |
|  |- interfaces/
|  |  |- interfaces.ts
|  |
|  |- middleware/
|  |  |- auth.middleware.ts
|  |
|  |- model/
|  |  |- user.model.ts
|  |
|  |- routes/
|  |  |- auth.route.ts
|  |  |- index.ts
|  |
|  |- types/
|  |
|  |- index.ts
|
|- static/
|
|- .env
|- .env.example
|- .gitignore
|- nodemon.json
|- package-lock.json
|- package.json
|- README.md
|- tsconfig.json

Frontend

If you use SPA for your frontend, copy compiled result into static folder.

Database

Set environment variable DB_SYNC=true to synchronize models and database. Otherwise, set it as false. Learn more about model synchronization here. Since Sequelize has various versions, you can check Sequelize official site here.