When you are starting a new backend project in
express there are things which are very common in every project and few files which are also required to be created in every project so, If you are going to start a new express project and want to quickly get started with basic app structure, database integration with ORM, JWT auth, linting, code styling, file-level logging, request validation, docker enabled then take a look here.
Every express project will have
index.js file to create an express app and start listening on any port. In Database, tables will at least have
users tables to store basic user details, and with users will surely have some sort of authentication mechanism, where mostly it's
JWT based authentication, so by keeping these things in mind, I made 2 boilerplates express apps one for Relation database (MySQL) using
sequelize ORM and second for Non-relational (MongoDB) database using
mongoose ORM. Both of these apps have
User model with basic user properties such as
password. Password is stored in hashed format and for authentication, it returns JWT token on successful login which is used to fetch all users API. So basically these boilerplates/starters have 3 APIs.
To imply best practices, these apps use
standard.js, for code styling it uses
prettier. (mysql one uses
standard.js for linting and styling while mongo one uses
prettier for code styling.)
Apps use express-validator for request body validation in
POST APIs, uses winston logger for logging error or debug data in file and console. I have tried to keep folder and code structure very simple to understand and to make changes according to your need.
These are my two boilerplate repos
- Relational with Mysql
- Non-relation with MongoDB
please show some ❤️ by starring ⭐ and making contributions in any form if you find anything.
And for developers who wants to contribute during this
hacktoberfest, I would love to have contributions for the following stuff:
- Ideas for any new boilerplate repo.
- test setup (priority)
- unit test cases with optimum code coverage. (priority)
- better API documentation in markdown or etc
- bugs or issues
I'm also working on two more, boilerplates repos which are not yet complete to get started which are
NOTE: If you're going to contribute then before starting to work on it please create an issue explaining the bug or enhancement you want to work on, I'll assign it to you so, that no two users can work on the same thing
Thank you, tell me what you think about it.