Skip to content

turivishal/restful-api-nodejs

Repository files navigation

README

This README would normally document whatever steps are necessary to get your application up and running.

What is this repository for?

Customized structure for RESTful API in NodeJS.

How do I get set up?

  • Pre Required:

  1. Download & Install latest NodeJS: https://nodejs.org/en/download/

  2. Download & Setup latest MongoDB server: https://www.mongodb.com/try/download/community

  • Setup:

  1. Clone repository
git clone https://github.com/turivishal/restful-api-nodejs.git
  1. Navigate to clone project directory
  2. Install dependencies
npm install
  1. 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 called server > 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 called mongodb > uris.
  2. 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
  1. Run project
npm start
  1. 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"}
  1. Open the link http://localhost:3000/api-docs in browser and it will open the swagger

image

Who do I talk to?