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_URI
inindex.js
.
Installation
- Run
npx rest-api-init
. - When prompted to install
rest-api-init
package, entery
- On completion, open terminal inside the root directory and run
npm start
- Open
localhost:5000
on 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.js
initializes the REST APIPORT
defines the port in which the server will run. The URL will look like this
localhost:<PORT>
DATABASE_URI
is configured for local database by default which needs MongoDB Compass to be installed.
routes/routes.js
will contain the routes e.g.get/post/patch/put/delete
models/model.js
will have the Schema defined for the database
Preferably define PORT
and DATABASE_URI
in a .env
file.