1.0.7 • Published 3 years ago
rest-api-init v1.0.7
rest-api-init
Fastest way to create REST API with Node.js, Express.js & MongoDB.
Prerequisites
- Node.js needs to be installed.
- MongoDB Compass needs to be installed only if you are running this api as it is. If you are using the MongoDB cloud database then just change the
DATABASE_URIinindex.js.
Installation
- Run
npx rest-api-init. - When prompted to install
rest-api-initpackage, entery - On completion, open terminal inside the root directory and run
npm start - Open
localhost:5000on your browser to view the textYour server is ready!
Features
- Fastest way to create a REST API
- Uses ES6 syntax
- Predefined template for express routes and mongoose model.
Configuration
index.jsinitializes the REST APIPORTdefines the port in which the server will run. The URL will look like thislocalhost:<PORT>DATABASE_URIis configured for local database by default which needs MongoDB Compass to be installed.
routes/routes.jswill contain the routes e.g.get/post/patch/put/deletemodels/model.jswill have the Schema defined for the database
Preferably define PORT and DATABASE_URI in a .env file.