Giter VIP home page Giter VIP logo

restaurant-api's Introduction

Restaurant App

This is an api for a restaurant app


Requirements

  1. User should be able to register
  2. User should be able to login
  3. Implement JWT authentication
  4. User should be able to get orders
  5. Users should be able to create orders
  6. Users should be able to update and delete orders
  7. Test application

Setup

  • Install NodeJS, mongodb
  • pull this repo
  • update env with example.env
  • run npm run dev

Base URL

  • somehostsite.com

Models


User

field data_type constraints
id string required
username string required
firstname string required
lastname string required
email string required
password string required
user_type string required, default: user, enum: ['user', 'admin']

APIs


Signup User

  • Route: /api/v1/signup
  • Method: POST
  • Body:
{
  "email": "[email protected]",
  "password": "Password1",
  "firstname": "jon",
  "lastname": "doe",
  "username": 'jon_doe",
}
  • Responses

Success

{
    message: 'Signup successful',
    user: {
        "email": "[email protected]",
        "password": "Password1",
        "firstname": "jon",
        "lastname": "doe",
        "username": 'jon_doe",
    }
}

Login User

  • Route: /api/v1/login
  • Method: POST
  • Body:
{
  "password": "Password1",
  "username": 'jon_doe",
}
  • Responses

Success

{
    message: 'Login successful',
    token: 'sjlkafjkldsfjsd'
}

Create Order

  • Route: /api/v1/orders
  • Method: POST
  • Header
    • Authorization: Bearer {token}
  • Body:
{
    items: [{ name: 'chicken pizza', price: 900, size: 'm', quantity: 1}]
}
  • Responses

Success

{
    state: 1,
    total_price: 900,
    created_at: Mon Oct 31 2022 08:35:00 GMT+0100,
    items: [{ name: 'chicken pizza', price: 900, size: 'm', quantity: 1}]
}

Get Order

  • Route: /api/v1/orders/:id
  • Method: GET
  • Header
    • Authorization: Bearer {token}
  • Responses

Success

{
    state: 1,
    total_price: 900,
    created_at: Mon Oct 31 2022 08:35:00 GMT+0100,
    items: [{ name: 'chicken pizza', price: 900, size: 'm', quantity: 1}]
}

Get Orders

  • Route: /api/v1/orders
  • Method: GET
  • Header:
    • Authorization: Bearer {token}
  • Query params:
    • page (default: 1)
    • per_page (default: 10)
    • order_by (default: created_at)
    • order (options: asc | desc, default: desc)
    • state
    • created_at
  • Responses

Success

{
    state: 1,
    total_price: 900,
    created_at: Mon Oct 31 2022 08:35:00 GMT+0100,
    items: [{ name: 'chicken pizza', price: 900, size: 'm', quantity: 1}]
}

...

Contributor

  • Emmanuel Asuquo

restaurant-api's People

Contributors

dannyrae 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.