1.0.9 • Published 3 years ago
express-mongo-boilerplate v1.0.9
Express Rest Boilerplate
A Minimal Starter Boilerplate for NodeJS REST API with ExpressJS & MongoDB.
Tech Stack
Language: JavaScript Server: NodeJS, ExpressJS Database: MongoDB
Project Structure
express-rest-boilerplate
┣ src
┃ ┣ config
┃ ┃ ┗ conn.js
┃ ┣ controllers
┃ ┃ ┣ auth
┃ ┃ ┃ ┣ auth.controller.js
┃ ┃ ┃ ┗ auth.validator.js
┃ ┃ ┣ user
┃ ┃ ┃ ┣ user.controller.js
┃ ┃ ┃ ┗ user.validator.js
┃ ┃ ┗ file.controller.js
┃ ┣ models
┃ ┃ ┗ User.model.js
┃ ┣ routes
┃ ┃ ┣ auth.routes.js
┃ ┃ ┣ file.routes.js
┃ ┃ ┗ user.routes.js
┃ ┣ utils
┃ ┃ ┣ config.js
┃ ┃ ┣ protected.js
┃ ┃ ┣ response.js
┃ ┃ ┗ securePassword.js
┃ ┗ view
┃ ┃ ┗ serverRunning.html
┣ uploads
┃ ┗ LOCAL_FILE_UPLOADS
┣ .gitignore
┣ LICENCE
┣ package.json
┣ README.md
┣ server.js
┗ yarn.lockHow to use?
You can use this template as starter package of express/mongo
Install as starter pack
To use as starter pack
npx express-mongo-boilerplate <folder_name>Connect with database
To connect with MongoDB please go to the src folder then open config folder.
cd src
cd configand open database file and add your database connection string like below.
module.exports = {
database:
'mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]',
}How to run?
For development environment:
npm run devIf you are using yarn
yarn devFor production environment:
npm startIf you are using yarn
yarn startPORT
In the development server by default, it will open at port 5000, and in the production server, it will open in the server's default port.