gessicacss / Social-Postify

A API to schedule and manage posts across multiple social media platforms effortlessly.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Password Manager

About

Social Postify is a api that enables users to create and schedule posts across multiple social media platforms. Users can create customized posts and select specific dates and times for each publication. The system supports scheduling multiple posts and provides a clear overview of scheduled posts.

Technologies

nestjs node.js typescript express.js prisma postgres npm

Routes

GET /health

A route to check if the application is running. Returns "I'm okay!" with status code 200.

Medias:

POST /medias

Medias represent the social media platforms where posts (publications) will be made, e.g., Facebook, Instagram, Twitter. Returns status code 400 Bad Request in the absence of mandatory fields. Prevents the creation of a new record with the same combination of title and username, returning status code 409 Conflict. If its sucessfull it returns a 201 status code. The request body should contain:

{
    "title": "Instagram",
    "username": "myusername"
}

GET /medias

Returns an empty array if no media is registered. Returns all registered media in the following format:

[
    {
        "id": 1,
        "title": "Instagram",
        "username": "myusername"
    },
    {
        "id": 2,
        "title": "Twitter",
        "username": "myusername"
    }
]

GET /medias/:id

Returns the record matching the provided ID. Returns status code 404 Not Found if no matching record is found.

[
    {
        "id": 1,
        "title": "Instagram",
        "username": "myusername"
    }
]

PUT /medias/:id

Updates the record matching the provided ID. Returns status code 404 Not Found if no matching record is found. Ensures that the change does not violate the unique title and username rule, returning status code 409 Conflict.

{
    "title": "Instagram",
    "username": "myusername-changed"
}

DELETE /medias/:id

Deletes the record matching the provided ID. Returns status code 404 Not Found if no matching record is found. Media can only be deleted if it is not part of any publication (scheduled or published), returning status code 403 Forbidden.

Posts:

Posts represent the content that will be posted on social media through a publication.

POST /posts

Receives title, text, and an optional image parameter in the request body. Returns status code 400 Bad Request in the absence of mandatory fields.

{
    "title": "Why you should have a guinea pig?",
    "text": "https://www.guineapigs.com/why-you-should-guinea"
}

GET /posts

Returns an empty array if no posts are registered. Returns all registered posts in the following format:

[
    {
        "id": 1,
        "title": "Why you should have a guinea pig?",
        "text": "https://www.guineapigs.com/why-you-should-guinea"
    },
    {
        "id": 2,
        "title": "Man dies after coding for 400 hours non-stop",
        "text": "https://www.devnews.com/dies-after-400",
        "image": "https://www.devnews.com/dead-dev.jpg"
    }
]

GET /posts/:id

Returns the record matching the provided ID. Returns status code 404 Not Found if no matching record is found.

[
    {
        "id": 1,
        "title": "Why you should have a guinea pig?",
        "text": "https://www.guineapigs.com/why-you-should-guinea"
    }
]

PUT /posts/:id

Updates the record matching the provided ID. Returns status code 404 Not Found if no matching record is found.

[
    {
        "title": "Why you shouldn't have a guinea pig?",
        "text": "https://www.guineapigs.com/why-you-should-guinea"
    }
]

DELETE /medias/:id

Deletes the record matching the provided ID. Returns status code 404 Not Found if no matching record is found. Posts can only be deleted if they are not part of any publication (scheduled or published), returning status code 403 Forbidden.

Publictions:

Publications are the scheduled posts on social media.

POST /publications

Receives mediaId, postId, and date parameters in the request body. Returns status code 400 Bad Request in the absence of mandatory fields. Returns status code 404 Not Found if no matching records are found for mediaId and postId.

{
    "mediaId": 1,
    "postId": 1,
    "date": "2023-08-21T13:25:17.352Z"
}

GET /publications

Returns an empty array if no publications are registered. Returns all registered publications in the following format:

[
    {
        "id": 1,
        "mediaId": 1,
        "postId": 1,
        "date": "2023-08-21T13:25:17.352Z"
    },
    {
        "id": 2,
        "mediaId": 2,
        "postId": 1,
        "date": "2023-08-21T13:25:17.352Z"
    }
]

Special filters: published (true/false): Filter for published or unpublished publications. after (date): Filter for publications after a specific date.

GET /publications/:id

Returns the record matching the provided ID. Returns status code 404 Not Found if no matching record is found.

[
    {
        "id": 1,
        "mediaId": 1,
        "postId": 1,
        "date": "2023-08-21T13:25:17.352Z"
    }
]

PUT /publications/:id

Updates the record matching the provided ID. Returns status code 403 Forbidden if attempting to change the information of a published publication; only scheduled publications can be modified. Returns status code 404 Not Found if no matching record is found. Returns status code 404 Not Found if no matching records are found for mediaId and postId.

[
    {
        "id": 1,
        "mediaId": 1,
        "postId": 1,
        "date": "2023-09-21T13:25:17.352Z"
    }
]

DELETE /publications/:id

Deletes the record matching the provided ID. Returns status code 404 Not Found if no matching record is found. Posts can only be deleted if they are not part of any publication (scheduled or published), returning status code 403 Forbidden.

How to run

  1. Clone this repository
  2. Install the dependencies
npm i
  1. Run prisma
npx run prisma migrate dev
  1. Run the back-end with
npm run start
  1. Access http://localhost:3000 on your browser to run the API.

About

A API to schedule and manage posts across multiple social media platforms effortlessly.


Languages

Language:TypeScript 98.1%Language:JavaScript 1.9%