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.
https://github.com/Amanmandal-M/SequelizeCheck.git
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>
.
node index.js
nodemon index.js
Note : You can use any of them .
├── 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 portMYSQLDATABASE
: your MySQL database nameMYSQLUSER
: your MySQL usernameMYSQLPASSWORD
: your MySQL passwordMYSQLHOST
: your MySQL hostnameMYSQLPORT
: your MySQL portNORMALKEY
: your secret key
{
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"),
}
}
{
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"),
}
}
{
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"),
},
}
{
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"),
},
}
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 |