Giter Site home page Giter Site logo

amanmandal-m / sequelizecheck Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 35 KB

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.

Home Page: https://sequelizecheck.up.railway.app/

JavaScript 100.00%
bcrypt dotenv express-js jsonwebtoken mysql node-js nodemon railway-deployment

sequelizecheck's Introduction

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

sequelizecheck's People

Contributors

amanmandal-m avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.