The Blogging API is a versatile web service that allows you to create, manage, and interact with blogs and comments. It includes user authentication to ensure secure access to specific functionalities. This API is designed using Node.js and Express and relies on MongoDB as the database.
-
GET /blogs
- Retrieves a list of all blogs.
-
POST /blogs
- Creates a new blog post. Requires authentication.
-
PUT /blogs/:blog_id
- Updates an existing blog post. Requires authentication.
-
DELETE /blogs/:blog_id
- Deletes a specific blog post. Requires authentication.
-
PATCH /blogs/:blog_id/like
- Records likes and dislikes for a blog post. Requires authentication.
-
PATCH /blogs/:blog_id/co-authors
- Manages co-authors for a blog post. Requires authentication.
-
GET /comments/:blog_id
- Retrieves all comments for a specific blog post.
-
POST /comments/:blog_id
- Adds a new comment to a blog post. Requires authentication.
-
PUT /comments/:blog_id/:comment_id
- Updates a specific comment on a blog post. Requires authentication.
-
DELETE /comments/:blog_id/:comment_id
- Deletes a specific comment on a blog post. Requires authentication.
-
POST /users/signup
- Registers a new user.
-
POST /users/login
- Logs in a user and generates a JWT token for authentication.
To use this API, follow these steps:
- Clone the repository:
git clone [repository-url]
- Install dependencies:
npm install
- Configure your environment variables.
- Start the server:
npm start
- You can now access the API at http://localhost:80
We have successfully deployed the Blogging API to an Amazon Web Services (AWS) EC2 instance to make it publicly accessible on the internet. You can access the API using the following public address:
Public API Address: http://13.53.125.231/blogs
Certain routes require authentication, which can be done by registering and logging in as a user. Use the /users/signup
endpoint to create a new user account and /users/login
to obtain a JWT token. Include this token in the headers of your requests as Authorization: Bearer [token]
to access authenticated endpoints.