A simple nodejs express server template
- Install required packages:
npm install
- Start the server. By default, it will start on http://0.0.0.0:4000
- production server
npm start
- development server (uses nodemon for reload on file changes)
npm run dev
This templates uses a simple MVC-like structure.
All server related files are placed in /src directory.
PROJECT TREE
- src ----------------------------- project source directory
- controllers ------------- api controllers. responsible for processing requests and generating responses
- AppController.js - main API controller
- .....
- models ----------------- business data, rules and logic
- .....
- App.js ------------------- main server file. don't break it
- Auth.js ------------------ middleware. prevents unauthorized requests
- config.js ---------------- main config file: bearer token; version; etc.
- controllers ------------- api controllers. responsible for processing requests and generating responses
- package.json
- README.md --------------- pls notice me
- axios - Promise based HTTP client for the browser and node.js
- body-parser - Node.js body parsing middleware.
- cors - CORS is a node.js package for providing a Connect/Express middleware that can be used to enable CORS with various options.
- express - Fast, unopinionated, minimalist web framework for node.
- nodemon - nodemon is a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the directory are detected.