This is a simple Blog API project.
- Create, read, update, and delete blog posts
- User authentication and authorization
-
Clone the repository:
git clone https://github.com/Abiodun001-world/blog_api.git
-
Navigate to the project directory:
cd blog_api -
Install dependencies:
npm install
-
Create a
.envfile in the root directory:
MONGO_URI=
JWT_SECRET=
JWT_EXPIRES_IN=
NODE_ENV=
- Start the development server:
npm start
- Access the API at
http://localhost:3000
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
-
User Registration:
- Endpoint:
POST /auth/signup - Body:
{"first_name":"test", "last_name":"endpoint", "email": "test@gmail.com", "password": "passord321" }
- Endpoint:
-
User Login:
- Endpoint:
POST /auth/signin - Body:
{ "email": "email@gmail.com", "password": "password123" }
- Endpoint:
-
Create a Blog:
- Endpoint:
POST /blogs - Body:
{ "title": "Blog Title", "description": "Details", "status": "draft/published" } - Requires Auth: Yes (Include the token in the headers)
- Endpoint:
-
Get All Blogs:
- Endpoint:
GET /blogs - Requires Auth: No (the route is public)
- Endpoint:
-
Get a Specific Blog by a blog id:
- Endpoint:
GET /blogs/:id - Requires Auth: No (the route is public)
- Endpoint:
-
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)
- Endpoint:
-
Delete a Blog:
- Endpoint:
DELETE /blogs/:id - Requires Auth: Yes (Include the token in the headers)
- Endpoint:
Access the live application here