/node-starter

Primary LanguageJavaScript

🍏 Node.js

Markdown Monster icon

πŸ“” Most used Node.js modules

  • express
  • dotenv
  • path
  • fs
  • axios / request-native-promise
  • moment
  • body-parser
  • cron
  • lodash
  • validator
  • nodemailer

  • mongoose
  • connect-mongo
  • express-session
  • bcrypt [Check if it's depricated]
  • cookieParser
  • jsonwebtoken
  • passport/passport-facebook/passport-jwt/passport-local
  • cors / helmet

πŸ“½ Project Arhitecture

🌲 Structure of a project

β”œβ”€ πŸ“ .vscode           [optional]
|   β”œβ”€ πŸ“œ settings.json [optional]
|   └─ πŸ“œ launch.json   [optional]
|
β”œβ”€ πŸ“ node_modules (auto-generate)
|
β”œβ”€ πŸ“ server
|   β”œβ”€ πŸ“ api
|   |   β”œβ”€ πŸ“ user
|   |   |   β”œβ”€ πŸ“œ ❔ index.js
|   |   |   β”œβ”€ πŸ“œ user.routes.js
|   |   |   β”œβ”€ πŸ“œ user.model.js
|   |   |   β”œβ”€ πŸ“œ user.controller.js
|   |   |   └─ πŸ“œ user.service.js
|   |   └── ...
|   |
|   β”œβ”€ πŸ“œ server.js
|   β”œβ”€ πŸ“œ router.js
|   β””β”€β”€πŸ“ services
|       β”œβ”€ πŸ“œ logger.js
|       β”œβ”€ πŸ“œ dbconfig.js
|       └─ πŸ“œ [mostly singleton modules, services, mailer, middleware, varibales]
|
|
β”œβ”€πŸ“ public
|   β”œβ”€πŸ“ views [.ejs, .html, .pug...]
|   β”œβ”€πŸ“ scripts [frontend javascript files .js ]
|   β”œβ”€πŸ“ stylesheets [.css, less. cess...]
|   β”œβ”€πŸ“ images
|   β””β”€πŸ“ assets [optional][media: files, audio, video...]
|
β”œβ”€ πŸ“œ .eslintrc.json / .eslintrc.js
β”œβ”€ πŸ“œ .package.json
β”œβ”€ πŸ“œ .package-lock.json (auto-generate)
β”œβ”€ πŸ“œ .gitignore
β”œβ”€ πŸ“œ .env (.staging.env && .production.env)
β”œβ”€ πŸ“œ Procfile (if you are deploying on heroku)
└─ πŸ“œ README.md

πŸ–₯ About arhitecture

api/<something>

  • <something>.routes.js - routers
  • <something>.model.js - DB collection
  • <something>.controller.js - logic
  • <something>.services.js - queries

πŸ—― Documentation comments

/**
*@description
*@return
*@params
*/
const functionName = [async]() => { };

πŸ”₯Swagger

Swagger configuration is in the server/services/swagger folder All documentation will be parsed from server/services/swagger/docs and name must finished with .swagger.js

πŸ“ Logger

Currently in logger.js I use winston logger