Skip to content

davidauza-engineer/mini_blog_platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

88 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Conventional Commits Powered by Docker Heroku

Mini Blog Platform

🐳 Running with Docker

This setup will run your Rails application in a Docker container with a PostgreSQL database, Redis and Sidekiq.

To run the application using Docker, follow these steps:

  1. Set up environment variables
    cp .env.example .env
  2. Build the Docker containers:
    docker compose build
  3. Start the Docker containers:
    docker compose up
  4. Access the application: Open your browser and navigate to http://localhost:3000.

Note: The application will be seeded with the entities at db/seeds.rb

πŸš€ Deployment

The app is deployed at Heroku.

Screenshot 2024-10-31 at 4 51 54β€―AM

βœ‰οΈ Note: Emails might be sent to the spam folder.

πŸ“ Public API Documentation

Base URL

https://guarded-dusk-82007-3d4643b2b311.herokuapp.com/api/v1

Endpoints

1. List Posts

Endpoint: /posts Method: GET Description: Retrieves a list of posts with pagination.

Parameters:

  • page (optional): Page number for pagination.
  • ids (optional): Comma-separated list of post IDs to filter.

Example Request:

curl -X GET "https://guarded-dusk-82007-3d4643b2b311.herokuapp.com/api/v1/posts?page=1"

Example Response:

[
  {
    "id": 2,
    "title": "Apple",
    "body": "Apple",
    "author_id": 24,
    "created_at": "2024-10-30T02:31:29.804Z",
    "updated_at": "2024-10-30T02:31:29.804Z",
    "comments": [
      {
        "id": 6,
        "body": "Commenting on someone else",
        "post_id": 2,
        "author_id": 23,
        "created_at": "2024-10-30T18:37:11.378Z",
        "updated_at": "2024-10-30T18:37:11.378Z"
      },
      {
        "id": 7,
        "body": "Yes!",
        "post_id": 2,
        "author_id": 23,
        "created_at": "2024-10-30T19:24:28.963Z",
        "updated_at": "2024-10-30T19:24:28.963Z"
      },
      {
        "id": 9,
        "body": "Email to icloud.",
        "post_id": 2,
        "author_id": 23,
        "created_at": "2024-10-30T19:46:15.411Z",
        "updated_at": "2024-10-30T19:46:15.411Z"
      }
    ]
  }
]

2. Get Post

Endpoint: /posts/:id Method: GET Description: Retrieves a specific post by ID.

Parameters:

  • id (required): ID of the post.

Example Request:

curl -X GET "https://guarded-dusk-82007-3d4643b2b311.herokuapp.com/api/v1/posts/1"

Example Response:

{
  "id": 1,
  "title": "Gmail",
  "body": "Testing with Gmail.",
  "author_id": 23,
  "created_at": "2024-10-30T02:29:10.790Z",
  "updated_at": "2024-10-31T03:54:25.045Z",
  "comments": [
    {
      "id": 2,
      "body": "Amazing! - edited\r\n",
      "post_id": 1,
      "author_id": 23,
      "created_at": "2024-10-30T02:29:33.392Z",
      "updated_at": "2024-10-30T02:29:42.549Z"
    },
    {
      "id": 4,
      "body": "Beautiful! - edited",
      "post_id": 1,
      "author_id": 24,
      "created_at": "2024-10-30T02:33:20.506Z",
      "updated_at": "2024-10-30T02:33:27.330Z"
    },
    {
      "id": 5,
      "body": "Commenting on myself",
      "post_id": 1,
      "author_id": 23,
      "created_at": "2024-10-30T18:31:46.875Z",
      "updated_at": "2024-10-30T18:31:46.875Z"
    },
    {
      "id": 8,
      "body": "Email to myself.",
      "post_id": 1,
      "author_id": 23,
      "created_at": "2024-10-30T19:45:47.462Z",
      "updated_at": "2024-10-30T19:45:47.462Z"
    }
  ]
}

3. Create Post

Endpoint: /posts Method: POST Description: Creates a new post.

Parameters:

  • title (required): Title of the post.
  • body (required): Body of the post.
  • author_id (required): ID of the author.

Example Request:

curl -X POST "https://guarded-dusk-82007-3d4643b2b311.herokuapp.com/api/v1/posts" -d '{ "post": { "title": "New Post", "body": "This is the body of the new post.", "author_id": 23 } }'

Example Response:

{
  "id": 5,
  "title": "New Post",
  "body": "This is the body of the new post.",
  "author_id": 23,
  "created_at": "2024-10-31T05:32:42.686Z",
  "updated_at": "2024-10-31T05:32:42.686Z"
}

4. Update Post

Endpoint: /posts/:id Method: PUT Description: Updates an existing post.

Parameters:

  • id (required): ID of the post.
  • title (optional): New title of the post.
  • body (optional): New body of the post.

Example Request:

curl -X PUT "https://guarded-dusk-82007-3d4643b2b311.herokuapp.com/api/v1/posts/5" -d '{ "post": { "title": "New Post - Edited" } }'

Example Response:

{
  "title": "New Post - Edited",
  "author_id": 23,
  "id": 5,
  "body": "This is the body of the new post.",
  "created_at": "2024-10-31T05:32:42.686Z",
  "updated_at": "2024-10-31T05:35:21.944Z"
}

5. Delete Post

Endpoint: /posts/:id Method: DELETE Description: Deletes a specific post by ID.

Parameters:

  • id (required): ID of the post.

Example Request:

curl -X DELETE "https://yourdomain.com/api/v1/posts/5"

About

Mini Blog Platform built with Ruby on Rails

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •