Skip to content

Abiodun001-world/blog_api

Repository files navigation

Blog API

This is a simple Blog API project.

Features

  • Create, read, update, and delete blog posts
  • User authentication and authorization

Installation and Setup

  1. Clone the repository:

    git clone https://github.com/Abiodun001-world/blog_api.git
  2. Navigate to the project directory:

    cd blog_api
  3. Install dependencies:

    npm install
  4. Create a .env file in the root directory:

MONGO_URI=
JWT_SECRET=
JWT_EXPIRES_IN=
NODE_ENV=

Usage

  1. Start the development server:
    npm start
  2. Access the API at http://localhost:3000

Testing the API

You can use tools like Postman or Insomnia to test the API endpoints and you can access the APIs for this project below:API endpoints

  1. User Registration:

    • Endpoint: POST /auth/signup
    • Body: {"first_name":"test", "last_name":"endpoint", "email": "test@gmail.com", "password": "passord321" }
  2. User Login:

    • Endpoint: POST /auth/signin
    • Body: { "email": "email@gmail.com", "password": "password123" }
  3. Create a Blog:

    • Endpoint: POST /blogs
    • Body: { "title": "Blog Title", "description": "Details", "status": "draft/published" }
    • Requires Auth: Yes (Include the token in the headers)
  4. Get All Blogs:

    • Endpoint: GET /blogs
    • Requires Auth: No (the route is public)
  5. Get a Specific Blog by a blog id:

    • Endpoint: GET /blogs/:id
    • Requires Auth: No (the route is public)
  6. Update a Blog by a blog id:

    • Endpoint: PUT /blogs/:id
    • Body: { "title": "Blog Title", "description": "Blog Description", "status": "draft/published" }
    • Requires Auth: Yes (Include the token in the headers)
  7. Delete a Blog:

    • Endpoint: DELETE /blogs/:id
    • Requires Auth: Yes (Include the token in the headers)

Hosting Link

Access the live application here

About

AltSchool Africa Second Semester Exam(Project Based)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published