🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

github.com/aanchalverma/Machine-Coding/blogging

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/aanchalverma/Machine-Coding/blogging

Source
Go
Version
v0.0.0-20241002044859-1f6626e8e65c
Version published
Created
Source

Blogging API

Requirements

  • Design and implement a RESTful API using any Programmatic language

    • Completed
  • Include endpoint(s) for retrieving all posts, retrieving a single post by ID, creating a new post, updating an existing post, and deleting a post.

    • Completed
  • Implement filtering for posts based on author and creation date.

    • Completed
  • Ensure that the API follows RESTful principles and returns appropriate HTTP status codes and error messages.

    • Completed
  • Implement authentication and authorization(Read/Write/Administer) mechanisms.

    • Completed
  • Implement pagination for retrieving a large number of posts.

    • Completed but doesn't fully work, needs testing
  • Design/Define database architecture (SQL or NoSQL) to persist the data.

    • Not completed
  • Write unit tests to validate the sanity of the application

    • Completed but doesn't work as expected
  • Provide API documentation for the same.

    • Done

Authentication

JWT-based authentication has been used where the user can

  • Register themselves
  • Generate token based on credentials
  • Use the generated token for REST services

POST /register

  • Request:
{
  "username": "user1",
  "password": "password1",
  "role": "write"
}

POST /login

  • Request: { "username": "user1", "password": "password1" }
  • Response: { "token": "<JWT_TOKEN>" }

Posts Endpoints

GET /posts

  • Retrieves all posts
  • Query parameters used:
    • page (for pagination, default 1)
    • limit (number of posts per page, default 10)

GET /posts/:id

  • Response : Retrieves a post by ID

POST /posts

  • Request:
{
  "title": "Post Title",
  "content": "Post content",
  "author": "Author"
}

3. Steps to Run and Test:

  • Run the application:
    go run main.go
    

FAQs

Package last updated on 02 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts