Skip to content

bimprakosoo/api-blog

Repository files navigation

API Service for Blog

This project is a web application that provides various APIs for managing blog posts.

Installation

To get started with the project, follow these steps:

  1. Clone the repository:
  2. git clone https://github.com/bimprakosoo/api-blog.git
  3. Change into the project directory:
  4. cd api-blog
  5. Install the dependencies using Composer:
  6. composer install
  7. Set up the database by creating a new database and configuring the .env file with your database credentials:
  8. cp .env.example .env

    Update the .env file with your database information.

  9. Generate the application key:
  10. php artisan key:generate
  11. Migrate the database:
  12. php artisan migrate
  13. Optionally, seed the database with sample data:
  14. php artisan db:seed

APIs

The following APIs are available in this project:

  • POST /api/register: User login. It accepts the name, email and password parameters and returns a JSON response telling user registered succesfully.
  • POST /api/login: User login. It accepts the email and password parameters and returns a JSON response containing the access token upon successful authentication.
  • POST /api/logout: User logout. It requires the Authorization header with the access token to invalidate the token and perform the logout operation.
  • GET /api/post: Get all blog posts. It returns a JSON response containing a list of all blog posts.
  • GET /api/post/{id}: Get a specific blog post by ID. It accepts the id parameter in the URL and returns a JSON response with the details of the blog post.
  • POST /api/post/add: Create a new blog post. It accepts the title, content,category_id, and tags_id parameters in the request body and creates a new blog post.
  • PUT /api/posts/edit/{id}: Update a blog post. It accepts the id parameter in the URL and the title, content, category_id, and tags_id parameters in the request body to update the specified blog post.
  • DELETE /api/post/delete/{id}: Delete a blog post. It accepts the id parameter in the URL to delete the specified blog post.
  • POST /api/category/add: Create a new category. It accepts the name parameter in the request body and creates a new category.
  • GET /api/category: Get all categories. It returns a JSON response containing a list of all categories.
  • GET /api/category/{id}: Get a specific category by ID. It accepts the id parameter in the URL and returns a JSON response with the details of the category.
  • PUT /api/category/edit/{id}: Update a category. It accepts the id parameter in the URL and the name parameters in the request body to update the specified category.
  • DELETE /api/category/delete/{id}: Delete a category. It accepts the id parameter in the URL to delete the specified category.
  • POST /api/tag/add: Create a new tag. It accepts the name parameter in the request body and creates a new tag.
  • GET /api/tag: Get all tags. It returns a JSON response containing a list of all categories.
  • GET /api/tag/{id}: Get a specific tag by ID. It accepts the id parameter in the URL and returns a JSON response with the details of the tag.
  • PUT /api/tag/edit/{id}: Update a tag. It accepts the id parameter in the URL and the name parameters in the request body to update the specified tag.
  • DELETE /api/tag/delete/{id}: Delete a tag. It accepts the id parameter in the URL to delete the specified tag.
  • POST /api/post/comments: Create a new comment. It accepts the post_id and content parameters in the request body to create a new comment for a specific blog post.

These APIs can be accessed using HTTP requests with the appropriate headers and parameters.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published