Skip to content

This is an Order Food Backend application that utilizes a MySQL database. The backend supports CRUD (Create, Read, Update, Delete) operations, allowing users to register, login, order food, and add food items.

Notifications You must be signed in to change notification settings

Amanmandal-M/SequelizeCheck

Repository files navigation

Order Food App Backend

About


This is an Order Food Backend application that utilizes a MySQL database. The backend supports CRUD (Create, Read, Update, Delete) operations, allowing users to register, login, order food, and add food items.


Clone a Repository

https://github.com/Amanmandal-M/SequelizeCheck.git

Installation

npm install
npm install -g nodemon

Note : Don't need to install packages if you only use this command all the packages automatically install if you want to add more packages then you have to write this command npm install <your package name>.

Start the Backend server

node index.js

nodemon index.js

Note : You can use any of them .


MVC Structure

├── index.js
├── configs
|    └── db.js
├── models
|    └── UserModel.js
|    └── OrderModel.js
├── routes
|    └── UserRouters.js
|    └── OrderRouters.js
├──middlewares
|    └── AuthenticationMiddleware.js
├──controllers
|    └── UserController.js
|    └── OrderController.js

Note :

  • Before doing anything first create .env file and put these things :
    • PORT : your server is listen in this port
    • MYSQLDATABASE : your MySQL database name
    • MYSQLUSER : your MySQL username
    • MYSQLPASSWORD : your MySQL password
    • MYSQLHOST : your MySQL hostname
    • MYSQLPORT : your MySQL port
    • NORMALKEY : your secret key

Schema Design


User Table

{
    id: {
        // `default value` you don't have to write this
    },
    Name: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    Email: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true,
    },
    Password: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    createdAt: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
    },
    updatedAt: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
    }
}

Orders Table

{
    id: {
        // `default value` you don't have to write this
    },
    ItemName: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    Quantity: {
        type: DataTypes.INTEGER,
        allowNull: false,
    },
    TotalPrice: {
        type: DataTypes.INTEGER,
        allowNull: false,
    },
    userID: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: UserModel.Users, // Provide the table name associated with the UserModel
            key: "id",
        },
    },
    createdAt: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
    },
    updatedAt: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
    },
}

Endpoints

METHOD ENDPOINT DESCRIPTION STATUS CODE
POST /auth/register This endpoint should allow users to register. Hash the password on store. 201
POST /auth/login This endpoint should allow users to login. Return JWT token on successful login 201
GET /orders/ This endpoint should return a list of all orders of current users. 200
GET /orders/:id This endpoint should return a single product of that current customer 200
POST /orders/create This endpoint should allow users to create a new order 201
PATCH /orders/:id This endpoint should allow the user to update order details 204
DELETE /orders/posts/:id This endpoint should allow users to delete a specific order identified by order id. 202

Backend Deployed Link :


MySQL is Depoloyed on Railway it is totally handled by Railway

About

This is an Order Food Backend application that utilizes a MySQL database. The backend supports CRUD (Create, Read, Update, Delete) operations, allowing users to register, login, order food, and add food items.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published