xkrsz / nemb

Node + Express + Mongoose boilerplate using TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nemb

Node + Express + Mongoose boilerplate

This projects contains everything you need to jump start your backend.

Usage:

To run nemb, just clone or download this repository, cd into it, execute npm install or yarn install and run project with npm start/yarn start or npm run start-nomongo/yarn run start-nomongo if you have MongoDB already running on default port.

nemb comes with a couple of ready scripts to make your workflow easier:

  • start: Restarts or runs MongoDB in background with database path set to db folder in this project, then runs server.js and reloads on change.
  • start-nomongo: Only runs server.js and reloads on change in source. Useful if you already have MongoDB running.
  • start-nowatch: Restarts or runs MongoDB and runs server.js, but doesn't watch for changes.

Libraries:

  • body-parser: Used to parse www-urlencoded format (data from html forms for example) and JSON.
  • cors: Self-explanatory.
  • express: Web framework.
  • mongoose: MongoDB object modeling. Makes using MongoDB much easier.
  • winston: Used for logging things.
  • nodemon: Runs project and restarts when changes are made.

Project structure

|____.gitignore
|____build
|____db
|____logs
|____src
| |____components
| | |____example
| | | |____example.js
| | | |____example.routes.js
| |____models
| | |____example.js
| |____modules
| | |____db.js
| | |____logger.js
| |____server.js
|____package.json
|____README.md

Project structure is meant to be scalable. Here are the rules you should obey while using this structure:

To do:

  • document boilerplate thoroughly
  • create a start command which starts everything
  • optional command to run without mongo (in case someone has it running already)
  • move to TypeScript

About

Node + Express + Mongoose boilerplate using TypeScript


Languages

Language:TypeScript 72.1%Language:JavaScript 27.9%