blog-api

command module
v0.0.0-...-252ed1e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 5 Imported by: 0

README

blog-api

An API for a blog service that allows users to create, view, update and delete posts without authorization.

No sign-ups required. Create a post right away with a username and some text.

This api could be used to for a web app like Telegraph. (👈🏾 Click on the link for context if necessary)

This Project was built as a submission for a Slightly Techie Network Challenge

API Documentation

Main URL: https://blog-api-kf6i.onrender.com/api/

Create Post

End Point: /post
Method: POST
Request Body:

{
    "username" : "mj",
    "title":"on beefs",
    "text" : "i took that personally"
}

Response:201 Created

{
    "success" : "post created"
}

View Post

End Point: /post/:postId
Method: GET
Example Request: /post/649c20f10f9ddfa97a24ef48
Response:200 OK

[
    {
        "Id": "649c20f10f9ddfa97a24ef48",
        "username": "mj",
        "title": "on beefs",
        "text": "i took that personally",
        "created_At": "2023-06-28T12:00:49Z",
        "updated_At": "2023-06-28T12:00:49Z",
        "post_id": "649c20f10f9ddfa97a24ef48"
    }
]

View All Posts From A User

End Point: /post/user/:username
Method: GET
Example Request: /post/user/mj
Response:200 OK

[
    {
        "Id": "649c20f10f9ddfa97a24ef48",
        "username": "mj",
        "title": "on beefs",
        "text": "i took that personally",
        "created_At": "2023-06-28T12:00:49Z",
        "updated_At": "2023-06-28T12:00:49Z",
        "post_id": "649c20f10f9ddfa97a24ef48"
    },
    {
        "Id": "649c24ad0f9ddfa97a24ef4a",
        "username": "mj",
        "title": "on kids",
        "text": "f*ck 'em kids",
        "created_At": "2023-06-28T12:16:45Z",
        "updated_At": "2023-06-28T12:16:45Z",
        "post_id": "649c24ad0f9ddfa97a24ef4a"
    }
]

View All Posts

End Point: /post
Method: GET
Response:200 OK

[
    {
        "Id": "649c20f10f9ddfa97a24ef48",
        "username": "mj",
        "title": "on beefs",
        "text": "i took that personally",
        "created_At": "2023-06-28T12:00:49Z",
        "updated_At": "2023-06-28T12:00:49Z",
        "post_id": "649c20f10f9ddfa97a24ef48"
    },
    {
        "Id": "649b8651ac77266faa2fd853",
        "username": "ja",
        "title": "that interview",
        "text": "im fine in the west",
        "created_At": "2023-06-28T01:01:05Z",
        "updated_At": "2023-06-28T01:01:05Z",
        "post_id": "649b8651ac77266faa2fd853"
    },
    {
        "Id": "649c24ad0f9ddfa97a24ef4a",
        "username": "mj",
        "title": "on kids",
        "text": "f*ck 'em kids",
        "created_At": "2023-06-28T12:16:45Z",
        "updated_At": "2023-06-28T12:16:45Z",
        "post_id": "649c24ad0f9ddfa97a24ef4a"
    }
]

Update Post

End Point: /post/:postId
Method: PUT
Example Request:/post/649b8632ac77266faa2fd851

{
    "username":"tidylearner",
    "title":"alomo gyata",
    "text":"me na me de me ho aba nea mo p3 biaa mo nfa ny3 me"
}

Set unrequired fields to ""
An example for updating just title and text

{
    "username":"",
    "title" : "RW",
    "text" : "real wai"
}

Response:200 OK

{
    "success" : "post updated"
}

Delete Post

End Point: /post/:postId
Method: DELETE
Example Request:/post/649b8632ac77266faa2fd851
Response:200 OK

{
    "success" : "post deleted"
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL