• Stars
    star
    125
  • Rank 286,335 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿš€ A boilerplate for Node.js api projects with Express.js, Sequelize, PostgreSQL and ES6+

Node.js CI

Express Starter

This project was created to be a template when starting a new express.js project.

Run on Google Cloud

Features

  1. ES6+ features with babel (including es6 import/export feature).
  2. SQL database implementation with Sequelize v6 for postgres dialect (you can change postgresql anytime).
  3. Compatible with 12 factor app.
  4. Including authentication system with rest api endpoints.
  5. Linting with eslint (airbnb config).
  6. Implemented nodemailer. If you are in development or test mode, you use test smtp account. In production mode, you use real smtp server. For more info, browse src/helpers/mail.js file.
  7. Production ready Dockerfile.
  8. Test cases written with mocha and chai.
  9. Implemented sentry error tracking.
  10. Api documentation with swagger.
  11. Records are never deleted from the database. They are marked as deleted.
  12. Cache management with redis.
  13. One click deploy to Google Cloud Run.

Api Documentation

Api documentation of this project was created with swagger.
You can access the swagger configuration file from this link.
You can also discover the interactive documentation by going to /docs when you run the application.

Database Selection

This project is compatible with sql-based databases. You can change default dialect (postgres) in anytime. To do this, firstly select your database from the table below. Modify dialect property in src/config/sequelize.js and install required npm package(s) for this database.

For more info, visit sequelize docs

Note: The default and active database is postgresql. If you want to use postgresql in your project, you don't need to make any changes.

Database Dialect Required npm Package(s)
MySQL mysql yarn add mysql2
MariaDB mariadb yarn add mariadb
PostgreSQL postgres yarn add pg pg-hstore
SQLite sqlite yarn add sqlite3
Microsoft SQL Server mssql yarn add tedious

Usage of sequelize-cli

With sequelize-cli package, you can manage model, migration and seed files. You can find more information with document.

Installation

  1. Firstly, you have to install npm packages with yarn install command.
  2. Create empty postgres database.
  3. Create .env file by copying .env.sample file in root directory.
  4. Modify .env file.
  5. Use yarn run db:migrate command to create database tables.
  6. Finally, your app will run successfully with yarn run start:dev command.

Authentication Endpoints

Route HTTP Verb Request Body Description
/auth/register POST {"firstName": "John", "lastName": "Doe", "email": "[email protected]", "password": "123456"} Create new user.
/auth/login POST {"email": "[email protected]", "password": "123456"} Login endpoint.
/auth/me GET Empty Fetch current user.
/auth/me PUT {"firstName": "John", "lastName": "Doe", "email": "[email protected]"} Update current user.
/auth/me DELETE Empty Delete current user.
/auth/me/password PUT {"current": "current-password", "password": "new-password"} Update password of current user.

Contribution

Anyone interested in the project can contribute to this repository. To do this, first fork the repository. Then make the changes in your repository. Finally, send a pull request to this repository.

License

Express Starter is licensed under the MIT license.