Skip to content

REST API Starter Template using Node JS, Express and MongoDB.

Notifications You must be signed in to change notification settings

urwah1248/Node-Express-Mongodb-Starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node JS, Express and MongoDB Starter template

This is a starter template for a REST API built on Node JS, Express and MongoDB.

Table of Contents

Getting Started

Follow the steps below to set up and run the REST API on your local machine.

Cloning the Repository

To get started, clone this repository to your local machine using the following command:

git clone https://github.com/urwah1248/Node-Express-Mongodb-Starter.git

Setting up Environment Variables

  1. Navigate to the root folder of the cloned repository.
  2. Create a new file named .env by copying the provided .env.example file.
  3. Edit the .env file and add your MongoDB URI to the MONGODB_URI variable. It should look something like this:
PORT=3000
MONGODB_URI=mongodb://your-username:your-password@your-host:your-port/your-database

Replace the placeholder values with your actual MongoDB credentials.

Installing Dependencies

Before running the application, you need to install its dependencies. Make sure you have Node.js and npm installed.

  1. Open a terminal or command prompt.
  2. Navigate to the root folder of the cloned repository.
  3. Run the following command to install the required dependencies:
npm install

Starting the Application

Once the dependencies are installed and the environment variables are set up, you can start the application. The start script is used for production, and the dev script is used for development.

To start the application in production mode, run:

npm start

To start the application in development mode, which uses tools like nodemon for automatic restarts on file changes, run:

npm run dev

The API will be available at http://localhost:3000 by default (you can change the port in the .env file).

About

REST API Starter Template using Node JS, Express and MongoDB.

Topics

Resources

Stars

Watchers

Forks