This backend application is built with Node.js and Express.js, utilizing MongoDB as its database to simplify menu management.
The v22.12.0 version of Node is required for the installation and building of this application.
- Clone this repository by running the following command in your terminal:
git clone https://github.com/Ktn-mariam/menu-management.git
cd menu-management
- Run the following command to install the dependencies:
npm install
This project is connected to a mongodb database. Create a project in mongodb and host a cluster. Get the connection string of the cluster and add it to your .env file. Here are the required variables:
MONGO_URI=
Run the following command to run the project:
npm start
Following is the project structure of this application:
├── src/
│ ├── api/ # Contains the main file
│ ├── controllers/ # API logic
│ ├── config/ # To connect to db
│ ├── errors/ # Error functions
│ ├── middlewares/ # Custom middleware
│ ├── models/ # Mongoose Schemas
│ ├── routes/ # Express routes
├── package.json
├── package-lock.json
├── README.md
├── .env
├── .gitignore
├── tsconfig.json
├── vercel.json
This NodeJS application has 3 APIs. The menu is divided into 3 parts: Category, SubCategory, and Item. Categories have subcategories. Items can be created under categories and subCategories.
The category API has the following 4 endpoints:
Action | Route | Method |
---|---|---|
Create Category | /api/v1/category |
POST |
Get All Categories | /api/v1/category |
GET |
Get Category | /api/v1/category/:categoryId |
GET |
Update Category | /api/v1/category/:categoryId |
PATCH |
The subCategory API has the following 4 endpoints:
Action | Route | Method |
---|---|---|
Create SubCategory | /api/v1/subCategory |
POST |
Get All SubCategories | /api/v1/subCategory |
GET |
Get All SubCategories Under Category | /api/v1/subCategory/category/:categoryId |
GET |
Get SubCategory | /api/v1/subCategory/:subCategoryId |
GET |
Update SubCategory | /api/v1/subCategory/:subCategoryId |
PATCH |
The item API has the following 7 endpoints:
Action | Route | Method |
---|---|---|
Create Item | /api/v1/item |
POST |
Get All Items | /api/v1/item |
GET |
Get All Items Under Category | /api/v1/item/category/:categoryId |
GET |
Get All Items Under SubCategory | /api/v1/item/subCategory/:subCategoryId |
GET |
Search Item by name | /api/v1/item/search?searchName= |
GET |
Get Item | /api/v1/item/:itemId |
GET |
Update Item | /api/v1/item/:itemId |
PATCH |
This application was deployed on Vercel. Make sure you enter the Environment Variables before deploying it. You also need to add vercel.json file with the following content:
{ "version": 2, "rewrites": [{ "source": "/(.*)", "destination": "/api" }] }
You also need to make sure the main file is named index.ts
and is in the /api folder.