Skip to content

pramesthias/IP-RMT42

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Review Assignment Due Date Open in Visual Studio Code

Individual Project Phase 2

CYTO is my Individual Project developed for assignment purposes. It is an application that can be accessed here:

This app has :

  • RESTful endpoint for asset's CRUD operation
  • JSON formatted response

 

RESTful endpoints

Users

POST /register

Register new user

Request Header

not needed

URL Params

not needed

Data Params

not needed

Request Body

{
    "username": "string",
    "email": "string",
    "password": "string",
}

Response (201 - Created)

{
    "id": integer,
    "username": "string"
}

Response (400 - Bad Request)

{
    "message": "Email cannot be Empty!"
        OR
    "message": "Email should be written in email format!"
        OR
    "message": "Password cannot be Empty!"
        OR
    "message": "Minimum password length is 8"
}

POST /login

User login

Request Header

not needed

URL Params

not needed

Data Params

not needed

Request Body

{
    "email": "string",
    "password": "string"
}

Response (200 - OK)

{
    "access_token": "string"
}

Response (400 - Bad Request)

{
    "message": "Error invalid email or password"
}

Response (401 - Unauthorized)

{
    "message": "User not found or Password not matched"
}

POST /google-login

User login via Google Account

Request Header

"g_token"

URL Params

not needed

Data Params

not needed

Request Body

{
    "email": "string",
    "username": "string",
    "password": "string"
}

Response (200 - OK)

{
    "access_token": "string"
}

Recipes

GET /recipes

Get All Recipes

Request Header

{"Authorization": "Bearer <access_token>"}

URL Params

not needed

Data Params

not needed

Request Body

not needed

Response (200 - OK)

[
    {
        "id": "string",
        "name": "string",
        "description": "string",
        "prepareTime": "string",
        "cookTime": "string",
        "ingredients": [
            "string",
            "string",
            "string",
            "string",
            "string",
            "string",
            "string",
            "string",
            "string",
            "string"
        ],
        "steps": [
            "string",
            "string",
            "string",
            "string",
            "string",
            "string",
            "string",
        ],
        "nutrients": {
            "string": integer,
            "string": integer,
            "string": integer,
            "string": integer,
            "string": integer,
            "string": integer,
            "string": integer,
            "string": integer
        },
        "image": "string"
    },
    ...
]

GET /recipe/:id

Get One Recipe by Id

Request Header

{"Authorization": "Bearer <access_token>"}

URL Params

id: integer [required]

Data Params

not needed

Request Body

not needed

Response (200 - OK)

{
    "id": "string",
    "name": "string",
    "description": "string",
    "prepareTime": "string",
    "cookTime": "string",
    "ingredients": [
        "string",
        "string",
        "string",
        "string",
        "string",
        "string",
        "string",
        "string",
        "string",
        "string"
    ],
    "steps": [
        "string",
        "string",
        "string",
        "string",
        "string",
        "string",
        "string",
    ],
    "nutrients": {
        "string": integer,
        "string": integer,
        "string": integer,
        "string": integer,
        "string": integer,
        "string": integer,
        "string": integer,
        "string": integer
    },
    "image": "string"
}

Response (404 - Not Found)

{
    "message": "Recipe not found"
}

Mail Sending

POST /contact-mail

Send Message to the CYTO team

Request Header

{"Authorization": "Bearer <access_token>"}

URL Params

not needed

Data Params

not needed

Request Body

{ 
    "username":"string", 
    "email": "string", 
    "message": "string" 
}

Response (200 - OK)

{
    "message": "Your message sent successfully"
}

Response (400 - Bad Request)

{
    "message": "Please fill the required form!"
}

Comment

GET /comment

Get all comments/posts

Request Header

{"Authorization": "Bearer <your access token>"}

URL Params

not needed

Data Params

not needed

Request Body

not needed

Response (200 - OK)

[
    {
        "imgUrl": "string",
        "username": "string",
        "description": "string",
        "userId": integer
        "createdAt": "date",
        "updatedAt": "date"
    },
    ...
]

POST/comment/add

Create new comment/post

Request Header

{"Authorization": "Bearer <your access token>"}

URL Params

not needed

Data Params

not needed

Request Body

{
    "imgUrl": "string",
    "username": "string",
    "description": "string",
    "userId": integer
}

Response (201 - Created)

{
    "id": integer,
    "username": "string",
    "description": "string",
    "userId": integer,
    "createdAt": "date",
    "updatedAt": "date"
}

PUT /comment/edit/:id

Edit comment/post by id

Request Header

{"Authorization": "Bearer <your access token>"}

URL Params

id: integer [required]

Data Params

not needed

Request Body

{
    "description": "string",
}

Response (201 - Created)

{
    "id": integer,
    "username": "string",
    "description": "string",
    "userId": integer,
    "createdAt": "date",
    "updatedAt": "date"
}

Response (404 - Not Found)

{
    "message": "Comment not found"
}

DELETE /comment/delete/:id

Delete comment/post by id

Request Header

{"Authorization": "Bearer <your access token>"}

URL Params

id: integer [required]

Data Params

not needed

Request Body

not needed

Response (200 - OK)

{
    "message": "Comment success to delete"
}

Response (404 - Not Found)

{
    "message": "Comment not found"
}

Global Error

Response (401 - Unauthorized)

{
    "message": "Unauthenticated"
}

Response (403 - Forbidden)

{
    "message": "You are not authorized"
}

Response (500 - Internal Server Error)

{
    "message": "Internal Server Error"
}

About

ip-rmt42 created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HTML 58.0%
  • JavaScript 39.5%
  • CSS 2.5%