This README would normally document whatever steps are necessary to get your application up and running.
Customized structure for RESTful API in NodeJS.
-
Download & Install latest NodeJS: https://nodejs.org/en/download/
-
Download & Setup latest MongoDB server: https://www.mongodb.com/try/download/community
- Download & Install MongoDB Compass or any MongoDB IDE.
- Clone repository
git clone https://github.com/turivishal/restful-api-nodejs.git
- Navigate to clone project directory
- Install dependencies
npm install
-
Configure
i) Port (optional)
- The default port is 3000, you can change if you want to, navigate to project directory >
app/config/development.yml
, in this file there is a property calledserver
>port
.
ii) Database connection (optional)
- The default connection link is "mongodb://localhost:27017/ProductLocal", you can change it as per your choice, navigate to project directory >
app/config/development.yml
, in this file there is a property calledmongodb
>uris
.
- The default port is 3000, you can change if you want to, navigate to project directory >
-
Create a
.env
file in the root directory of the project, and declare 2 variables for environment config file selection
PROFILE=development
NODE_ENV=development
- Run project
npm start
- You will see the console message
> [email protected] start
> node app.js
info: We are working on DEVELOPMENT environment and Listening on port 3000... {"timestamp":"2022-10-05 16:57:19:551"}
info: MongoDB connection succeeded! {"timestamp":"2022-10-05 16:57:19:574"}
- Open the link http://localhost:3000/api-docs in browser and it will open the swagger