A demo Restaurant on boarding application for food delivery system with NodeJS, Express and MongoDB.
The project includes web application and REST APIs. This project is built with NodeJS for backend, Express is the framework used and MongoDB is the database. For demo, Template engine EmbeddedJS is used to render web and rest apis can be tested with Postman.
- Node - Download and install
- MongoDb Server - Install MongoDB Community Edition (instructions) and run it by executing mongod.
- ExpressJS - It’s a flexible Node.JS web appplication framework that has many features for web and mobile applications
- Mongoose - MongoDB ODM for Node.JS.
- EmbeddedJS - Simple templating language that lets us generate HTML markup with plain JavaScript.
- Clone this Git repository
- Make sure Node is installed. To check, run
node -v
in cmd/terminal. - Make sure MongoDb Server is installed and running. To check, run
mongo --version
in cmd/terminal and executemongod
to start server. If some error occured check path in environment variables. - From project directory run
npm install
, It will install all dependencies required. - Configure database connection in
database.js
located insidesrc/config/..
. If database is not created, create db: runmongo
>>use <db_name>
. - Set
port
, only if you need to change, Currently running on 4000. - Finally, To start run
npm start
.
app.js
- The entry point to our application. This file defines our express server. It also requires the routes and models we'll be using in the application.config/
- This folder contains configuration files such as database connections, etc.routes/
- This folder contains the route definitions for our API.models/
- This folder contains the schema definitions for our Mongoose models.controllers/
- This folder contains controllers which is the logic of how the app handles the incoming requests and outgoing responses.views/
- This folder contains webview pages to render.public/
- This folder contains static files.
Currently cofigured to run it on local machine.
Just make sure that your server is still running on the port number 4000.
-
Postman - A popular API client, can be used for testing rest api.
-
Fetch restaurants with:
- URL: http://localhost:4000/api/restaurants
- Method: GET
-
Register a restaurant with:
- URL: http://localhost:4000/api/restaurants
- Method: POST
- Body: raw + JSON (application/json)
- Body Content:
{ "name":"ABC Restaurant", "contact_name":"Jon", "pincode":"676301", "location":"Koramangala", "website":"https://www.google.com/", "phone":"9746438811", "avg_daily_trans":"12000" }
-
run (http://localhost:4000/): It will show restaurants list.
- By clicking on 'JOIN', user can register Restaurant with name, contact name, phone, location, etc and submit.