Skip to content

A REST-API framework to handle all the back-end tasks for a food-ordering application.

License

Notifications You must be signed in to change notification settings

pratyushranjan2/Food-Order-Rest-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PRODUCTION SERVER BASE URL

https://ranjan-food-order.herokuapp.com
The URL is only for making API requests.

REQUESTS

Create User

Creates a new user/customer account.

  • URL
    /users

  • METHOD
    POST

  • DATA PARAMS

    • REQUIRED:
      name=[String]
      email=[String]
      roll=[String]
      password=[String]
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "user": { "_id": "612776587eb003001548428e", "name": "Pratyush Ranjan", "email": "[email protected]", "roll": "imt2019000", "__v": 1 }, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MTI3NzY1ODdlYjAwMzAwMTU0ODQyOGUiLCJpYXQiOjE2Mjk5NzYxNTIsImV4cCI6MTYzMDU4MDk1Mn0.6WrlgR-wnrqh2pAHTY5tgdvLHl9JKY1xktfb0rh_LBU" }
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Login User

Logs in an existing user.

  • URL
    /users/login

  • METHOD
    POST

  • DATA PARAMS

    • REQUIRED:
      email=[String]
      password=[String]
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "user": { "_id": "60fe5f0366d658001515f875", "name": "Pratyush", "email": "[email protected]", "roll": "imt2019065", "__v": 3 }, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MGZlNWYwMzY2ZDY1ODAwMTUxNWY4NzUiLCJpYXQiOjE2Mjk5NzY5MDAsImV4cCI6MTYzMDU4MTcwMH0.RARaL0czG1lfO3r1s5saNo4m8gXqB2S1sTK8gdVGsAg" }
  • ERROR RESPONSE

    • CODE: 400
    • CONTENT: { error: [Object] }


Log Out User

Logs out the user from the current device.

  • URL
    /users/logout

  • METHOD
    POST

  • AUTHORIZATION

    • User Authentication
      Bearer Authentication Token
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "message": "Logged out" }
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Log Out User Everywhere

Logs out the user from all device from which he/she had logged in.

  • URL
    /users/logoutAll

  • METHOD
    POST

  • AUTHORIZATION

    • User Authentication
      Bearer Authentication Token
  • SUCCESS RESPONSE

    • CODE: 200
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Get User Details

Fetches the details of the user currently logged in.

  • URL
    /users/me

  • METHOD
    GET

  • AUTHORIZATION

    • User Authentication
      Bearer Authentication Token
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "_id": "60fe5f0366d658001515f875", "name": "Pratyush", "email": "[email protected]", "roll": "imt2019065", "__v": 7 }
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Delete User

Deletes the user currently logged in.

  • URL
    /users/me

  • METHOD
    DELETE

  • AUTHORIZATION

    • User Authentication
      Bearer Authentication Token
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "_id": "60fe5f0366d658001515f875", "name": "Pratyush", "email": "[email protected]", "roll": "imt2019065", "__v": 7 }
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Update User Details

Updates the modifiable user account parameters.

  • URL
    /users/me

  • METHOD
    PATCH

  • AUTHORIZATION

    • User Authentication
      Bearer Authentication Token
  • DATA PARAMS

    • ALLOWED:
      name=[String]
      email=[String]
      roll=[String]
      password=[String]

    • RESTRICTED:
      tokens=[{token}]

  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "message": "Updated successfully" }
  • ERROR RESPONSE

    • CODE: 400
    • CONTENT: { error: [Object] }


Create Admin

Creates a new admin account. Only one admin account can be created. Only if the present admin is removed, can the next admin be created.

  • URL
    /admin

  • METHOD
    POST

  • DATA PARAMS

    • REQUIRED:
      name=[String]
      email=[String]
      password=[String]
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "admin": { "_id": "612776587eb003001548428e", "name": "Admin", "email": "[email protected]", "password": "adminiiitb", "__v": 1 }, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MTI3NzY1ODdlYjAwMzAwMTU0ODQyOGUiLCJpYXQiOjE2Mjk5NzYxNTIsImV4cCI6MTYzMDU4MDk1Mn0.6WrlgR-wnrqh2pAHTY5tgdvLHl9JKY1xktfb0rh_LBU" }
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Login Admin

Logs in the existing admin.

  • URL
    /admin/login

  • METHOD
    POST

  • DATA PARAMS

    • REQUIRED:
      email=[String]
      password=[String]
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "admin": { "_id": "60fe9b235ef7790015164c5d", "name": "Admin", "email": "[email protected]", "__v": 5 }, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MGZlOWIyMzVlZjc3OTAwMTUxNjRjNWQiLCJpYXQiOjE2Mjk5ODM5ODgsImV4cCI6MTYzMDU4ODc4OH0.spwvTMoENa3vk4FYx71a-hm20UaW7UCqq0gM96Mcme8" }
  • ERROR RESPONSE

    • CODE: 400
    • CONTENT: { error: [Object] }


Log Out Admin

Logs out the admin from the current device.

  • URL
    /admin/logout

  • METHOD
    POST

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "message": "Logged out" }
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Log Out Admin Everywhere

Logs out the admin from all device from which he/she had logged in.

  • URL
    /admin/logoutAll

  • METHOD
    POST

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: {message: 'Logged out from all devices'}
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Update Admin Details

Updates the modifiable admin account parameters.

  • URL
    /admin/current

  • METHOD
    PATCH

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • DATA PARAMS

    • ALLOWED:
      name=[String]
      email=[String]
      password=[String]

    • RESTRICTED:
      tokens=[{token}]

  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "message": "Details updated successfully" }
  • ERROR RESPONSE

    • CODE: 400
    • CONTENT: { error: [Object] }


Create Food

Adds a new food item to the database.

  • URL
    /food

  • METHOD
    POST

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • DATA PARAMS

    • REQUIRED:
      name=[String]
      price=[String]
      availability=[Boolean]

    • OPTIONAL:
      discount=[Number]
      stock=[Number]

  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "message": "Food successfully added" }
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Get Food

Fetches the food details of a particular food.

  • URL
    /food/:id

  • METHOD
    GET

  • URL PARAMS

    • REQUIRED:
      id=[mongoose.Schema.Types.ObjectId]
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "_id": "612798386ad0390015574a0a", "name": "Dosa", "price": 50, "availability": true, "stars": 5, "description": "Medium-sized dosa. Serves 1.", "discount": 10, "__v": 0 }
  • ERROR RESPONSE

    • CODE: 404
    • CONTENT: { error: [Object] }


Get Foods

Fetches multiple foods according to filters provided(if any). Pagination supported through limit and skip as query parameters.

  • URL
    /food

  • METHOD
    GET

  • URL PARAMS

    • OPTIONAL:
      limit:[Integer]
      skip:[Integer]
  • BODY PARAMS

    • OPTIONAL:
      name:[String]
      price:[Number]
      discount:[Number]
      availability:[Boolean]
      stars:[Number]
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: [{ "_id": "612798386ad0390015574a0a", "name": "Dosa", "price": 50, "availability": true, "stars": 5, "description": "Medium-sized dosa. Serves 1.", "discount": 10, "__v": 0 }, { "_id": "612798386ad0390015574a0a", "name": "Dosa", "price": 50, "availability": true, "stars": 5, "description": "Medium-sized dosa. Serves 1.", "discount": 10, "__v": 0 }]
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Update Food Details

Updates the modifiable food parameters in the database.

  • URL
    /food/:id

  • METHOD
    PATCH

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • URL PARAMS

    • REQUIRED:
      id=[mongoose.Schema.Types.ObjectId]
  • DATA PARAMS

    • ALLOWED:
      name=[String]
      price=[Number]
      availability=[Boolean]
      discount=[Number]
      stock=[Number]

    • RESTRICTED:
      stars=[Number]

  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { [Food] }
  • ERROR RESPONSE

    • CODE: 400
    • CONTENT: { error: [Object] }


Delete Food

Deletes the food from the database.

  • URL
    /food/:id

  • METHOD
    DELETE

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • URL PARAMS

    • REQUIRED:
      id=[mongoose.Schema.Types.ObjectId]
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "_id": "612798386ad0390015574a0a", "name": "Dosa", "price": 50, "availability": true, "stars": 5, "description": "Medium-sized dosa. Serves 1.", "discount": 10, "__v": 0 }
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Create Order

Creates a new food-order.

  • URL
    /order/:foodID

  • METHOD
    POST

  • AUTHORIZATION

    • User Authentication
      Bearer Authentication Token
  • URL PARAMS

    • REQUIRED:
      foodID=[mongoose.Schema.Types.ObjectId]
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "message": "Order created" }
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Get Order

Fetches the details of an order.

  • URL
    /orders/:id

  • METHOD
    GET

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • URL PARAMS

    • REQUIRED:
      id=[mongoose.Schema.Types.ObjectId]
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: { "quantity": 1, "paid": false, "_id": "6127b447e53db0001516aad2", "owner": "612784af7eb00300154842ab", "food": "6127b3d7e53db0001516aac7", "createdAt": "2021-08-26T15:33:27.298Z", "updatedAt": "2021-08-26T15:33:27.298Z", "__v": 0 }
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }
      OR
    • CODE: 404
    • CONTENT: { error: 'No order found' }


Get Orders

Fetches multiple orders according to filters provided(if any). Pagination supported through limit and skip as query parameters.

  • URL
    /orders

  • METHOD
    GET

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • URL PARAMS

    • OPTIONAL:
      limit:[Integer]
      skip:[Integer]
      paid:[Boolean]
  • SUCCESS RESPONSE

    • CODE: 200
    • CONTENT: [{ "quantity": 1, "paid": false, "_id": "6127b447e53db0001516aad2", "owner": "612784af7eb00300154842ab", "food": "6127b3d7e53db0001516aac7", "createdAt": "2021-08-26T15:33:27.298Z", "updatedAt": "2021-08-26T15:33:27.298Z", "__v": 0 }, { "quantity": 2, "paid": true, "_id": "6127b447e53db0001516aae9", "owner": "612784af7eb00300154842sg", "food": "6127b3d7e53db0001516aaqe", "createdAt": "2021-08-26T13:33:27.298Z", "updatedAt": "2021-08-26T11:33:27.298Z", "__v": 0 }]
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Delete Order

Deletes the order from the database.

  • URL
    /order/:id

  • METHOD
    DELETE

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • URL PARAMS

    • REQUIRED:
      id=[mongoose.Schema.Types.ObjectId]
  • SUCCESS RESPONSE

    • CODE: 200
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Upload User Avatar

Uploads an avatar/profile-pic for the user.

  • URL
    /users/me/avatar

  • METHOD
    POST

  • AUTHORIZATION

    • User Authentication
      Bearer Authentication Token
  • BODY PARAMS

    • REQUIRED:
      avatar=[File(png/jpg/jpeg)]
  • SUCCESS RESPONSE

    • CODE: 200
    • Content: { 'message': 'Image uploaded' }
  • ERROR RESPONSE

    • CODE: 400
    • CONTENT: { error: [Object] }


Upload Food Image

Uploads an image for a food.

  • URL
    /food/:id/image

  • METHOD
    POST

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • URL PARAMS

    • REQUIRED:
      id=[mongoose.Schema.Types.ObjectId]
  • BODY PARAMS

    • REQUIRED:
      image=[File(png/jpg/jpeg)]
  • SUCCESS RESPONSE

    • CODE: 200
    • Content: { 'message': 'Image uploaded' }
  • ERROR RESPONSE

    • CODE: 400
    • CONTENT: { error: [Object] }


Get User Avatar

Fetches the avatar of a user.

  • URL
    /users/:id/avatar

  • METHOD
    GET

  • URL PARAMS

    • REQUIRED:
      id=[mongoose.Schema.Types.ObjectId]
  • SUCCESS RESPONSE

    • CODE: 200
    • Content: image/png
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Get Food Image

Fetches the image of a food.

  • URL
    /food/:id/image

  • METHOD
    GET

  • URL PARAMS

    • REQUIRED:
      id=[mongoose.Schema.Types.ObjectId]
  • SUCCESS RESPONSE

    • CODE: 200
    • Content: image/png
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Delete User Avatar

Deletes the avatar/profile-pic of the user.

  • URL
    /users/me/avatar

  • METHOD
    DELETE

  • AUTHORIZATION

    • User Authentication
      Bearer Authentication Token
  • SUCCESS RESPONSE

    • CODE: 200
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


Delete Food Image

Deletes the image of a food.

  • URL
    /food/:id/image

  • METHOD
    DELETE

  • AUTHORIZATION

    • Admin Authentication
      Bearer Authentication Token
  • URL PARAMS

    • REQUIRED:
      id=[mongoose.Schema.Types.ObjectId]
  • SUCCESS RESPONSE

    • CODE: 200
  • ERROR RESPONSE

    • CODE: 500
    • CONTENT: { error: [Object] }


About

A REST-API framework to handle all the back-end tasks for a food-ordering application.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published