Skip to content

This project is an API designed for a MiniBlog platform.

Notifications You must be signed in to change notification settings

leticia-de-araujo/miniblog-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniBlog API Documentation

Content Table


1. Overview

This project is an API designed for a MiniBlog platform.

The API was structured around 4 Entities/Tables:

  • Authors
  • Articles
  • Categories
  • Comments

These were the main technologies used in this project:


1.1. Author


2. Entity Relationship Diagram

Back to the top

ERD


3. Getting Started

Back to the top

3.1. Installing Dependencies

Clone the project on your machine and install dependencies with the command:

yarn

3.2. Environment Variables

Then create a .env file, copying the .env.example file format:

cp .env.example .env

Set your environment variables with your Postgres credentials and a new database of your choice.

3.3. Migrations

Run migrations with the command:

yarn typeorm migration:run -d src/data-source.ts

3.4. Tests

Run tests with the command:

yarn test

4. Authentication

Back to the top

Some routes need authentication. The authentication used is the Bearer Token type.

The token is generated automatically at Author Login.

Thus, to access routes with authentication, it is necessary to create an author and be logged in with that author.

In addition, some routes require the author to be the owner of the account, or the author who created the article or the category.

Please read each route's documentation to understand which authentications are required.


5. Endpoints

Back to the top

Index


1. Authors

Back to endpoints index

The Author object is defined as:

Field Type Description
id string Author's unique identifier
firstName string Author's first name
lastName string Author's last name
age number Author's age
email string Author's email
password string Author's password
articles array Articles written by author
categories array Categories created by author

Endpoints

Method Route Description
POST /authors Creates an author
GET /authors List all authors
GET /authors/:authorId Lists an author using its ID as a parameter
PATCH /authors/:authorId Updates an author using its ID as a parameter
DELETE /authors/:authorId Deletes an author using its ID as a parameter

POST /authors

Back to endpoints index


Request:


Request body example

{
  "firstName": "Sarah",
  "lastName": "Spencer",
  "age": 29,
  "email": "[email protected]",
  "password": "HJsuiv87*"
}

Expected Response:


Status 201 - Created

{
  "message": "Author registered successfully.",
  "author": {
    "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
    "firstName": "Sarah",
    "lastName": "Spencer",
    "age": 29,
    "email": "[email protected]"
  }
}

Error Responses:


Status 400 - Missing required field

{
  "status": "Error",
  "code": 400,
  "message": "(any object key) is a required field."
}

Status 400 - Invalid data type or length

{
  "status": "Error",
  "code": 400,
  "message": "yup error message"
}

Status 409 - Email already registered

{
  "status": "Error",
  "code": 409,
  "message": "This email has already been registered."
}

GET /authors

Back to endpoints index


Request:


Expected Response:


Status 200 - OK

{
  "message":  "Successful request.",
  "authors": [
    {
      "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
      "firstName": "Sarah",
      "lastName": "Spencer",
      "age": 29,
      "email": "[email protected]",
      "articles": [],
      "categories": []
    },
    ...
  ]
}

Error Responses:


  • No expected errors

GET /authors/:authorId

Back to endpoints index


Request:


Expected Response:


Status 200 - OK

{
  "message": "Successful request.",
  "author": {
    "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
    "firstName": "Sarah",
    "lastName": "Spencer",
    "age": 29,
    "email": "[email protected]",
    "articles": [],
    "categories": []
  }
}

Error Responses:


Status 404 - Author not found

{
  "status": "Error",
  "code": 404,
  "message": "Author not found."
}

PATCH /authors/:authorId

Back to endpoints index


Request:


Request headers

{
  "authorization": "Bearer Token"
}

Request body example

{
  "firstName?": "Sarah",
  "lastName?": "Spencer",
  "age?": 29,
  "email?": "[email protected]"
}
  • At least one field is required

Expected Responses:


Status 200 - OK

{
  "message": "Author updated successfully.",
  "author": {
    "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
    "firstName": "Sarah",
    "lastName": "Spencer",
    "age": 29,
    "email": "[email protected]",
    "articles": [],
    "categories": []
  }
}

Expected Errors:


Status 401 - Missing authorization token

{
  "status": "Error",
  "code": 401,
  "message": "Missing authorization token."
}

Status 401 - Invalid token

{
  "status": "Error",
  "code": 401,
  "message": "Invalid token."
}

Status 401 - Author is not the account owner

{
  "status": "Error",
  "code": 401,
  "message": "Author is not the account owner."
}

Status 409 - Email already registered

{
  "status": "Error",
  "code": 409,
  "message": "This email has already been registered."
}

Status 400 - Invalid data type or length

{
  "status": "Error",
  "code": 400,
  "message": "yup error message"
}

Status 404 - Author not found

{
  "status": "Error",
  "code": 404,
  "message": "Author not found."
}

DELETE /authors/:authorId

Back to endpoints index


Request:


Request headers

{
  "authorization": "Bearer Token"
}

Expected Response:


Status 200 - OK

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

Expected Errors:


Status 401 - Missing authorization token

{
  "status": "Error",
  "code": 401,
  "message": "Missing authorization token."
}

Status 401 - Invalid token

{
  "status": "Error",
  "code": 401,
  "message": "Invalid token."
}

Status 401 - Author is not the account owner

{
  "status": "Error",
  "code": 401,
  "message": "Author is not the account owner."
}

Status 404 - Author not found

{
  "status": "Error",
  "code": 404,
  "message": "Author not found."
}


2. Login

Back to endpoints index

The Login object is defined as:

Field Type Description
email string Author's email
password string Author's password

Endpoints

Method Route Description
POST /login Login author

POST /login

Back to endpoints index


Request:

Request body example

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

Expected Response:


Status 200 - OK

{
  "message": "Successful login.",
  "token": "yJhbGciOiJIUzI1NiJ9.eyJSb2xlIjoiQWRtaW4iLCJJc3N1ZXIiOiJJc3N1ZXIiLCJVc2VybmFtZSI6IkphdmFJblVzZSIsImV4cCI6MTY2MjY4ODU1OCwiaWF0IjoxNjYyNjg4NTU4fQ.OONsla408_ohD5XE9b3-qfWaniZC95pgyBetmJeKViA"
}

Error Responses:


Status 400 - Missing required field

{
  "status": "Error",
  "code": 400,
  "message": "email/password is a required field"
}

Status 401 - Invalid email or password

{
  "status": "Error",
  "code": 401,
  "message": "Invalid email or password."
}


3. Articles

Back to endpoints index

The Article object is defined as:

Field Type Description
id string Article unique identifier
title string Article title
description string Article description
text string Article text
author object Article author
category null or object Article category
comments array Article comments

Endpoints

Method Route Description
POST /articles Creates an article
GET /articles List all articles
GET /articles/:articleId Lists an article using its ID as a parameter
PATCH /articles/:articleId Updates an article using its ID as a parameter
DELETE /articles/:articleId Deletes an article using its ID as a parameter

POST /articles

Back to endpoints index


Request:


Request headers

{
  "authorization": "Bearer Token"
}

Request body example

{
  "title": "The Little Mermaid: Why the Outdated Princess Movie Needed a Remake",
  "description": "While the original Little Mermaid is considered to be a Disney classic, there are still some solid reasons warranting the 2023 remake.",
  "text": "The reimagined live-action Disney classics have become a controversial topic around the internet. Bringing favorite fairy tales to live-action is a dream come true for many and a nightmare for others. Regardless, Disney's remakes have become a guilty pleasure for many moviegoers, and sometimes have more room to develop their characters and create nuance in plot (due to modern screenwriters, longer runtimes, and more). Aladdin added more political intrigue, The Jungle Book brought innovative CGI and cameras to the industry, and Cruella updated its soundtrack and fashion. With all the praise and complaints these movies generate, audiences are wondering what Disney will add to its next live action film.",
  "authorId": "d409d0ed-2e04-4682-8b23-cd0b8084c3ea"
}

Expected Response:


Status 201 - Created

{
  "message": "Article created successfully.",
  "article": {
    "id": "b5ecc3e6-ca7e-4d5c-824a-56f1dbc1aec1",
    "title": "The Little Mermaid: Why the Outdated Princess Movie Needed a Remake",
    "description": "While the original Little Mermaid is considered to be a Disney classic, there are still some solid reasons warranting the 2023 remake.",
    "text": "The reimagined live-action Disney classics have become a controversial topic around the internet. Bringing favorite fairy tales to live-action is a dream come true for many and a nightmare for others. Regardless, Disney's remakes have become a guilty pleasure for many moviegoers, and sometimes have more room to develop their characters and create nuance in plot (due to modern screenwriters, longer runtimes, and more). Aladdin added more political intrigue, The Jungle Book brought innovative CGI and cameras to the industry, and Cruella updated its soundtrack and fashion. With all the praise and complaints these movies generate, audiences are wondering what Disney will add to its next live action film.",
    "author": {
      "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
      "firstName": "Sarah",
      "lastName": "Spencer",
      "age": 29,
      "email": "[email protected]"
    }
  }
}

Error Responses:


Status 401 - Missing authorization token

{
  "status": "Error",
  "code": 401,
  "message": "Missing authorization token."
}

Status 401 - Invalid token

{
  "status": "Error",
  "code": 401,
  "message": "Invalid token."
}

Status 400 - Missing required field

{
  "status": "Error",
  "code": 400,
  "message": "(any object key) is a required field."
}

Status 400 - Invalid data type or length

{
  "status": "Error",
  "code": 400,
  "message": "yup error message"
}

Status 409 - Title already registered

{
  "status": "Error",
  "code": 409,
  "message": "There is already an article with this title."
}

Status 404 - Author not found

{
  "status": "Error",
  "code": 404,
  "message": "Author not found."
}

GET /articles

Back to endpoints index


Request:


Expected Response:


Status 200 - OK

{
  "message":  "Successful request.",
  "articles": [
    {
      "id": "b5ecc3e6-ca7e-4d5c-824a-56f1dbc1aec1",
      "title": "The Little Mermaid: Why the Outdated Princess Movie Needed a Remake",
      "description": "While the original Little Mermaid is considered to be a Disney classic, there are still some solid reasons warranting the 2023 remake.",
      "text": "The reimagined live-action Disney classics have become a controversial topic around the internet. Bringing favorite fairy tales to live-action is a dream come true for many and a nightmare for others. Regardless, Disney's remakes have become a guilty pleasure for many moviegoers, and sometimes have more room to develop their characters and create nuance in plot (due to modern screenwriters, longer runtimes, and more). Aladdin added more political intrigue, The Jungle Book brought innovative CGI and cameras to the industry, and Cruella updated its soundtrack and fashion. With all the praise and complaints these movies generate, audiences are wondering what Disney will add to its next live action film.",
      "author": {
        "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
        "firstName": "Sarah",
        "lastName": "Spencer",
        "age": 29,
        "email": "[email protected]"
      },
      "category": null,
      "comments": []
    },
    ...
  ]
}

Error Responses:


  • No expected errors

GET /articles/:articleId

Back to endpoints index


Request:


Expected Response:


Status 200 - OK

{
  "message": "Successful request.",
  "article": {
    "id": "b5ecc3e6-ca7e-4d5c-824a-56f1dbc1aec1",
    "title": "The Little Mermaid: Why the Outdated Princess Movie Needed a Remake",
    "description": "While the original Little Mermaid is considered to be a Disney classic, there are still some solid reasons warranting the 2023 remake.",
    "text": "The reimagined live-action Disney classics have become a controversial topic around the internet. Bringing favorite fairy tales to live-action is a dream come true for many and a nightmare for others. Regardless, Disney's remakes have become a guilty pleasure for many moviegoers, and sometimes have more room to develop their characters and create nuance in plot (due to modern screenwriters, longer runtimes, and more). Aladdin added more political intrigue, The Jungle Book brought innovative CGI and cameras to the industry, and Cruella updated its soundtrack and fashion. With all the praise and complaints these movies generate, audiences are wondering what Disney will add to its next live action film.",
    "author": {
      "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
      "firstName": "Sarah",
      "lastName": "Spencer",
      "age": 29,
      "email": "[email protected]"
    },
    "category": null,
    "comments": []
  }
}

Error Responses:


Status 404 - Article not found

{
  "status": "Error",
  "code": 404,
  "message": "Article not found."
}

PATCH /articles/:articleId

Back to endpoints index


Request:


Request headers

{
  "authorization": "Bearer Token"
}

Request body example

{
  "title?": "The Little Mermaid: Understand the 2023 remake",
  "description?": "While the original Little Mermaid is considered to be a Disney classic, there are still some solid reasons warranting the 2023 remake.",
  "text?": "The reimagined live-action Disney classics have become a controversial topic around the internet. Bringing favorite fairy tales to live-action is a dream come true for many and a nightmare for others. Regardless, Disney's remakes have become a guilty pleasure for many moviegoers, and sometimes have more room to develop their characters and create nuance in plot (due to modern screenwriters, longer runtimes, and more). Aladdin added more political intrigue, The Jungle Book brought innovative CGI and cameras to the industry, and Cruella updated its soundtrack and fashion. With all the praise and complaints these movies generate, audiences are wondering what Disney will add to its next live action film.",
  "categoryId?": "2e87d7cc-3541-49f9-a5e6-4030c8184a46"
}
  • At least one field is required

Expected Responses:


Status 200 - OK

{
  "message": "Article updated successfully.",
  "article": {
    "id": "b5ecc3e6-ca7e-4d5c-824a-56f1dbc1aec1",
    "title": "The Little Mermaid: Understand the 2023 remake",
    "description": "While the original Little Mermaid is considered to be a Disney classic, there are still some solid reasons warranting the 2023 remake.",
    "text": "The reimagined live-action Disney classics have become a controversial topic around the internet. Bringing favorite fairy tales to live-action is a dream come true for many and a nightmare for others. Regardless, Disney's remakes have become a guilty pleasure for many moviegoers, and sometimes have more room to develop their characters and create nuance in plot (due to modern screenwriters, longer runtimes, and more). Aladdin added more political intrigue, The Jungle Book brought innovative CGI and cameras to the industry, and Cruella updated its soundtrack and fashion. With all the praise and complaints these movies generate, audiences are wondering what Disney will add to its next live action film.",
    "author": {
      "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
      "firstName": "Sarah",
      "lastName": "Spencer",
      "age": 29,
      "email": "[email protected]"
    },
    "category": {
      "id": "2e87d7cc-3541-49f9-a5e6-4030c8184a46",
      "name": "Entertainment",
      "type": "Movies"
    }
  }
}

Expected Errors:


Status 401 - Missing authorization token

{
  "status": "Error",
  "code": 401,
  "message": "Missing authorization token."
}

Status 401 - Invalid token

{
  "status": "Error",
  "code": 401,
  "message": "Invalid token."
}

Status 401 - User is not the author who wrote this article

{
  "status": "Error",
  "code": 401,
  "message": "User is not the author who wrote this article."
}

Status 409 - Title already registered

{
  "status": "Error",
  "code": 409,
  "message": "There is already an article with this title."
}

Status 400 - Invalid data type or length

{
  "status": "Error",
  "code": 400,
  "message": "yup error message"
}

Status 404 - Article not found

{
  "status": "Error",
  "code": 404,
  "message": "Article not found."
}

DELETE /articles/:articleId

Back to endpoints index


Request:


Request headers

{
  "authorization": "Bearer Token"
}

Expected Response:


Status 200 - OK

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

Expected Errors:


Status 401 - Missing authorization token

{
  "status": "Error",
  "code": 401,
  "message": "Missing authorization token."
}

Status 401 - Invalid token

{
  "status": "Error",
  "code": 401,
  "message": "Invalid token."
}

Status 401 - User is not the author who wrote this article

{
  "status": "Error",
  "code": 401,
  "message": "User is not the author who wrote this article."
}

Status 404 - Article not found

{
  "status": "Error",
  "code": 404,
  "message": "Article not found."
}


4. Categories

Back to endpoints index

The Category object is defined as:

Field Type Description
id string Category unique identifier
name string Category name
type string Category type
author object Category author
articles array Articles in this category

Endpoints

Method Route Description
POST /categories Creates a category
GET /categories List all categories
GET /categories/:categoryId Lists a category using its ID as a parameter
PATCH /categories/:categoryId Updates a category using its ID as a parameter
DELETE /categories/:categoryId Deletes a category using its ID as a parameter

POST /categories

Back to endpoints index


Request:


Request headers

{
  "authorization": "Bearer Token"
}

Request body example

{
  "name": "Entertainment",
  "type": "Movies",
  "authorId": "d409d0ed-2e04-4682-8b23-cd0b8084c3ea"
}

Expected Response:


Status 201 - Created

{
  "message": "Category created successfully.",
  "category": {
    "id": "9f61e25a-abb4-4bf5-a29b-d4aab8d79a2a",
    "name": "Entertainment",
    "type": "Movies",
    "author": {
      "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
      "firstName": "Sarah",
      "lastName": "Spencer",
      "age": 29,
      "email": "[email protected]"
    }
  }
}

Error Responses:


Status 401 - Missing authorization token

{
  "status": "Error",
  "code": 401,
  "message": "Missing authorization token."
}

Status 401 - Invalid token

{
  "status": "Error",
  "code": 401,
  "message": "Invalid token."
}

Status 400 - Missing required field

{
  "status": "Error",
  "code": 400,
  "message": "(any object key) is a required field."
}

Status 400 - Invalid data type or length

{
  "status": "Error",
  "code": 400,
  "message": "yup error message"
}

Status 409 - Name already registered

{
  "status": "Error",
  "code": 409,
  "message": "There is already a category with this name."
}

Status 404 - Author not found

{
  "status": "Error",
  "code": 404,
  "message": "Author not found."
}

GET /categories

Back to endpoints index


Request:


Expected Response:


Status 200 - OK

{
  "message":  "Successful request.",
  "categories": [
    {
      "id": "9f61e25a-abb4-4bf5-a29b-d4aab8d79a2a",
      "name": "Entertainment",
      "type": "Movies",
      "author": {
        "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
        "firstName": "Sarah",
        "lastName": "Spencer",
        "age": 29,
        "email": "[email protected]"
      },
      "articles": []
    },
    ...
  ]
}

Error Responses:


  • No expected errors

GET /categories/:categoryId

Back to endpoints index


Request:


Expected Response:


Status 200 - OK

{
  "message": "Successful request.",
  "category": {
    "id": "9f61e25a-abb4-4bf5-a29b-d4aab8d79a2a",
    "name": "Entertainment",
    "type": "Movies",
    "author": {
      "id": "f1719800-2e5a-4270-88de-64380f73dd3d",
      "firstName": "Sarah",
      "lastName": "Spencer",
      "age": 29,
      "email": "[email protected]"
    },
    "articles": []
  }
}

Error Responses:


Status 404 - Category not found

{
  "status": "Error",
  "code": 404,
  "message": "Category not found."
}

PATCH /categories/:categoryId

Back to endpoints index


Request:


Request headers

{
  "authorization": "Bearer Token"
}

Request body example

{
  "name?": "Entertainment",
  "type?": "Movies and TV Shows"
}
  • At least one field is required

Expected Responses:


Status 200 - OK

{
  "message": "Category updated successfully.",
  "category": {
    "id": "9f61e25a-abb4-4bf5-a29b-d4aab8d79a2a",
    "name": "Entertainment",
    "type": "Movies and TV Shows"
  }
}

Expected Errors:


Status 401 - Missing authorization token

{
  "status": "Error",
  "code": 401,
  "message": "Missing authorization token."
}

Status 401 - Invalid token

{
  "status": "Error",
  "code": 401,
  "message": "Invalid token."
}

Status 401 - User is not the author that created this category

{
  "status": "Error",
  "code": 401,
  "message": "User is not the author that created this category."
}

Status 409 - Name already registered

{
  "status": "Error",
  "code": 409,
  "message": "There is already a category with this name."
}

Status 400 - Invalid data type or length

{
  "status": "Error",
  "code": 400,
  "message": "yup error message"
}

Status 404 - Category not found

{
  "status": "Error",
  "code": 404,
  "message": "Category not found."
}

DELETE /categories/:categoryId

Back to endpoints index


Request:


Request headers

{
  "authorization": "Bearer Token"
}

Expected Response:


Status 200 - OK

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

Expected Errors:


Status 401 - Missing authorization token

{
  "status": "Error",
  "code": 401,
  "message": "Missing authorization token."
}

Status 401 - Invalid token

{
  "status": "Error",
  "code": 401,
  "message": "Invalid token."
}

Status 401 - User is not the author that created this category

{
  "status": "Error",
  "code": 401,
  "message": "User is not the author that created this category."
}

Status 404 - Category not found

{
  "status": "Error",
  "code": 404,
  "message": "Category not found."
}


5. Comments

Back to endpoints index

The Comment object is defined as:

Field Type Description
id string Comment unique identifier
text string Comment text
article object Article of this comment

Endpoints

Method Route Description
POST /comments Creates a comment
GET /comments List all comments
GET /comments/:commentId Lists a comment using its ID as a parameter
PATCH /comments/:commentId Updates a comment using its ID as a parameter
DELETE /comments/:commentId Deletes a comment using its ID as a parameter

POST /comments

Back to endpoints index


Request:


Request body example

{
  "text": "Loved this article!",
  "articleId": "430be73d-1159-437e-961f-d46f18505471"
}

Expected Response:


Status 201 - Created

{
  "message": "Comment created successfully.",
  "comment": {
    "id": "2ef3011c-63e9-4b49-9d87-af23f5b3e676",
    "text": "Loved this article!",
    "article": {
      "id": "b5ecc3e6-ca7e-4d5c-824a-56f1dbc1aec1",
      "title": "The Little Mermaid: Understand the 2023 remake",
      "description": "While the original Little Mermaid is considered to be a Disney classic, there are still some solid reasons warranting the 2023 remake.",
      "text": "The reimagined live-action Disney classics have become a controversial topic around the internet. Bringing favorite fairy tales to live-action is a dream come true for many and a nightmare for others. Regardless, Disney's remakes have become a guilty pleasure for many moviegoers, and sometimes have more room to develop their characters and create nuance in plot (due to modern screenwriters, longer runtimes, and more). Aladdin added more political intrigue, The Jungle Book brought innovative CGI and cameras to the industry, and Cruella updated its soundtrack and fashion. With all the praise and complaints these movies generate, audiences are wondering what Disney will add to its next live action film."
    }
  }
}

Error Responses:


Status 400 - Missing required field

{
  "status": "Error",
  "code": 400,
  "message": "(any object key) is a required field."
}

Status 400 - Invalid data type or length

{
  "status": "Error",
  "code": 400,
  "message": "yup error message"
}

Status 409 - Text already registered

{
  "status": "Error",
  "code": 409,
  "message": "There is already a comment with this text."
}

Status 404 - Article not found

{
  "status": "Error",
  "code": 404,
  "message": "Article not found."
}

GET /comments

Back to endpoints index


Request:


Expected Response:


Status 200 - OK

{
  "message":  "Successful request.",
  "comments": [
    {
      "id": "2ef3011c-63e9-4b49-9d87-af23f5b3e676",
      "text": "Loved this article!",
      "article": {
        "id": "b5ecc3e6-ca7e-4d5c-824a-56f1dbc1aec1",
        "title": "The Little Mermaid: Understand the 2023 remake",
        "description": "While the original Little Mermaid is considered to be a Disney classic, there are still some solid reasons warranting the 2023 remake.",
        "text": "The reimagined live-action Disney classics have become a controversial topic around the internet. Bringing favorite fairy tales to live-action is a dream come true for many and a nightmare for others. Regardless, Disney's remakes have become a guilty pleasure for many moviegoers, and sometimes have more room to develop their characters and create nuance in plot (due to modern screenwriters, longer runtimes, and more). Aladdin added more political intrigue, The Jungle Book brought innovative CGI and cameras to the industry, and Cruella updated its soundtrack and fashion. With all the praise and complaints these movies generate, audiences are wondering what Disney will add to its next live action film."
      }
    },
    ...
  ]
}

Error Responses:


  • No expected errors

GET /comments/:commentId

Back to endpoints index


Request:


Expected Response:


Status 200 - OK

{
  "message": "Successful request.",
  "comment": {
    "id": "2ef3011c-63e9-4b49-9d87-af23f5b3e676",
    "text": "Loved this article!",
    "article": {
      "id": "b5ecc3e6-ca7e-4d5c-824a-56f1dbc1aec1",
      "title": "The Little Mermaid: Understand the 2023 remake",
      "description": "While the original Little Mermaid is considered to be a Disney classic, there are still some solid reasons warranting the 2023 remake.",
      "text": "The reimagined live-action Disney classics have become a controversial topic around the internet. Bringing favorite fairy tales to live-action is a dream come true for many and a nightmare for others. Regardless, Disney's remakes have become a guilty pleasure for many moviegoers, and sometimes have more room to develop their characters and create nuance in plot (due to modern screenwriters, longer runtimes, and more). Aladdin added more political intrigue, The Jungle Book brought innovative CGI and cameras to the industry, and Cruella updated its soundtrack and fashion. With all the praise and complaints these movies generate, audiences are wondering what Disney will add to its next live action film."
    }
  }
}

Error Responses:


Status 404 - Comment not found

{
  "status": "Error",
  "code": 404,
  "message": "Comment not found."
}

PATCH /comments/:commentId

Back to endpoints index


Request:


Request body example

{
  "text": "Really liked this article!"
}
  • It is necessary to send a text to be able to edit a comment.

Expected Responses:


Status 200 - OK

{
  "message": "Comment updated successfully.",
  "comment": {
    "id": "2ef3011c-63e9-4b49-9d87-af23f5b3e676",
    "text": "Really liked this article!",
    "article": {
      "id": "b5ecc3e6-ca7e-4d5c-824a-56f1dbc1aec1",
      "title": "The Little Mermaid: Understand the 2023 remake",
      "description": "While the original Little Mermaid is considered to be a Disney classic, there are still some solid reasons warranting the 2023 remake.",
      "text": "The reimagined live-action Disney classics have become a controversial topic around the internet. Bringing favorite fairy tales to live-action is a dream come true for many and a nightmare for others. Regardless, Disney's remakes have become a guilty pleasure for many moviegoers, and sometimes have more room to develop their characters and create nuance in plot (due to modern screenwriters, longer runtimes, and more). Aladdin added more political intrigue, The Jungle Book brought innovative CGI and cameras to the industry, and Cruella updated its soundtrack and fashion. With all the praise and complaints these movies generate, audiences are wondering what Disney will add to its next live action film."
    }
  }
}

Expected Errors:


Status 409 - Text already registered

{
  "status": "Error",
  "code": 409,
  "message": "There is already a comment with this text."
}

Status 400 - Invalid data type or length

{
  "status": "Error",
  "code": 400,
  "message": "yup error message"
}

Status 404 - Comment not found

{
  "status": "Error",
  "code": 404,
  "message": "Comment not found."
}

DELETE /comments/:commentId

Back to endpoints index


Request:


Expected Response:


Status 200 - OK

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

Expected Errors:


Status 404 - Comment not found

{
  "status": "Error",
  "code": 404,
  "message": "Comment not found."
}


About

This project is an API designed for a MiniBlog platform.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published