GithubHelp home page GithubHelp logo

recipe's Introduction

Recipe API

My API implementation to support the Trial Project described in this link.

The entire API runs on Node.js and is fully written in TypeScript.

It utilizes MongoDB for fetching and storing of data, which is being ran in docker. (see docker-compose.yml)

It follows the Route-Controller-Service structure for ExpressJS.

Node version used: v16.19.0.

Setup Database

docker compose up -d

Install Dependencies

npm install

Run the tests (make sure database is up)

npm test

Build App

npm run build

Run App (ts-node)

npm run dev

Seed First Admin

npm run seed:admin

API

The API endpoints' request and response are described below. Though I highly suggest to check the test cases ./test as it already serves as a good documentation.

Registration

Request

POST /register

localhost:3000/register

{
    "email": "[email protected]",
    "password": "password"
}

Response

201

{
    "message": "Account successfully created."    
}

Login

Request

POST /login

localhost:3000/login

{
    "email": "[email protected]",
    "password": "password"
}

Response

200

{
    "message": "Login successful."   
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImUxNmU3NzU4LWU1YTYtNDFlNy1iYmM2LTMzNWI1NTgyZTI0YyIsInJvbGUiOiJBRE1JTiIsImlhdCI6MTY3NDg3MTI0OSwiZXhwIjoxNjc0ODcxODQ5fQ.LbcqSk6bOT8TTGgiobLG9TW_KLkwv-f9ospclanAScQ" 
}

Creating User

Request

POST /users/add

localhost:3000/users/add

"authorization": "Bearer token..."

{
    "email": "[email protected]",
    "password": "password",
    "role: "ADMIN"
}

Response

201

{
    "message": "User successfully created."    
}

Listing Users

Request

GET /users

localhost:3000/users

"authorization": "Bearer token..."

Response

200

{
    "users": [
        "id": "1..."
        "email": "[email protected]"
        "password": "hashed..."
        "role": "ADMIN"
    ]    
}

Updating User

Request

PUT /users/update/:id

localhost:3000/users/update/1...

"authorization": "Bearer token..."

{
    "email": "[email protected]",
}

Response

200

{
    "message": "User successfully updated."    
}

Deleting User

Request

DELETE /users/delete/:id

localhost:3000/users/update/1...

"authorization": "Bearer token..."

Response

200

{
    "message": "User successfully deleted."    
}

Creating Recipe

Request

POST /recipes/add

localhost:3000/recipes/add

"authorization": "Bearer token..."

{
    "name": "name1",
    "ingredients": "ingredients1",
    "instructions: "instructions1"
}

Response

201

{
    "message": "Recipe successfully created."    
}

Listing Recipes

Request

GET /recipes

localhost:3000/recipes

"authorization": "Bearer token..."

Response

200

{
    "recipes": [
        "id": "1..."
        "name": "name1",
        "ingredients": "ingredients1",
        "instructions: "instructions1",
        "createdBy": "1..."
    ]    
}

Updating Recipe

Request

PUT /recipes/update/:id

localhost:3000/recipes/update/1...

"authorization": "Bearer token..."

{
    "name": "updatedname",
}

Response

200

{
    "message": "Recipe successfully updated."    
}

Deleting Recipe

Request

DELETE /recipes/delete/:id

localhost:3000/users/recipe/1...

"authorization": "Bearer token..."

Response

200

{
    "message": "Recipe successfully deleted."    
}

recipe's People

Contributors

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