This project was created to be a template when starting a new express.js project.
- ES6+ features with babel (including es6 import/export feature).
- SQL database implementation with Sequelize v6 for postgres dialect (you can change postgresql anytime).
- Compatible with 12 factor app.
- Including authentication system with rest api endpoints.
- Linting with eslint (airbnb config).
- 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. - Production ready Dockerfile.
- Test cases written with mocha and chai.
- Implemented sentry error tracking.
- Api documentation with swagger.
- Records are never deleted from the database. They are marked as deleted.
- Cache management with redis.
- One click deploy to Google Cloud Run.
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 |
With sequelize-cli package, you can manage model, migration and seed files. You can find more information with document.
- Firstly, you have to install npm packages with
yarn install
command. - Create empty postgres database.
- Create .env file by copying .env.sample file in root directory.
- Modify .env file.
- Use
yarn run db:migrate
command to create database tables. - Finally, your app will run successfully with
yarn run start:dev
command.
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. |
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.
Express Starter is licensed under the MIT license.