Skip to content

Latest commit

 

History

History
80 lines (56 loc) · 2.33 KB

File metadata and controls

80 lines (56 loc) · 2.33 KB

Antiqbras-Blog API

Overview

This simple API enables writers to manage blog posts and their accounts. It supports operations like creating, editing, and deleting posts, as well as managing writer accounts.

Features

Writers

  • Management: Writers can create, edit, and delete blog posts.
  • Account Creation: Writers have the ability to create other writer accounts.
  • Default Writer: A default writer account is always present upon application setup. The details of this default writer can be modified in the ".env" file (refer to ".env.example").

Posts

  • Structure: Each post contains a title, subtitle, content, slug, image, and the associated writer.
  • Accessibility: Posts are publicly viewable. However, creation, editing, or deletion of posts requires writer authentication.

Routes

Posts

  • GET "/posts": Fetches all posts. Supports query parameters: "page" (page number) and "pageSize" (number of posts per page, default is 5).

  • GET "/posts/:slug": Retrieves detailed information of a post using its slug.

  • POST "/posts": Creates a new post; requires authentication.

    {
      "hero_image": "https://i.imgur.com/cool_image",
      "title": "My first Post",
      "subtitle": "Best subtitle",
      "content": "Lorem Ipsum"
    }
  • PUT "/posts/:id": Edits a specific post by its ID; requires authentication.

  • DELETE "/posts/:id": Deletes a specific post by its ID; requires authentication.

Writer

  • POST "/writers/login": Generates a JWT token for authenticating certain routes. Requires valid writer credentials. A default writer can be set up in the ".env" file.

    {
      "username": "example_writer",
      "password": "123"
    }
  • POST "/writers/register": Registers a new writer; requires authentication.

    {
      "username": "new_writer",
      "author": "John Doe",
      "password": "123"
    }
  • GET "/writers/:username": Retrieves information about a specific writer using their username; requires authentication.

Environment Setup

  • Docker: The application uses Docker. Database configurations can be set in the ".env" file (see ".env.example").

Running the Database

docker-compose -f ./docker-compose.yml up

Running the API

go run .

To-Do

  • Implement roles for writers.
  • Add pagination