Skip to content

Backend

Mohammadreza Amini edited this page Jul 28, 2021 · 2 revisions

Safe-Crossing Backend

REST API written in Node.js using the Express.js web application framework and MongoDB for our database.

Other services used include:

Config

Create .env file in the Backend folder with this content:

DB_URL="mongodb+srv://user:password@server"

To run the backend you have 2 choices:

Docker

To run the docker container you have 2 choices:

  • Manually

Build docker container:

docker build -t safe-crossing-backend .

Run docker container:

docker run -p 3000:3000 -p 8888:8888 safe-crossing-backend

or

docker run -p 3000:3000 -p 8888:8888 -d safe-crossing-backend

to run the docker container in detached mode (runs in the background).

  • Run Script

Simply type the following in your cmd:

# the run script builds and runs the docker container
sudo sh run.sh

or

# the run script builds and runs the docker container in detached mode
sudo sh run.sh -d

to run the docker container in detached mode (runs in the background).

Node

Install dependencies using npm:

npm install

You can then start your backend.

npm start

And access using your browser.

http://localhost:3000/api/

Documentation

To read more about:

  • MongoDB object modeling with Mongoose.

  • Real-time, bidirectional, event-based communication with Socket.IO.

Clone this wiki locally