express-mongo-boilerplate
v1.0.9
Published
A Minimal Starter Boilerplate for NodeJS REST API with ExpressJS & MongoDB.
Downloads
3
Readme
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.lock
How 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 config
and 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 dev
If you are using yarn
yarn dev
For production environment:
npm start
If you are using yarn
yarn start
PORT
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.