BlogApi is a comprehensive backend system designed for bloggers and readers alike. It enables users to register, login, create, read, and manage blog posts. Additionally, there is a comment system allowing users to interact with the content. This API provides a solid foundation for any blogging platform.
Follow these steps to set up and run the project on your local machine:
Before you proceed, ensure you have the following software installed on your system:
- Node.js
- MongoDB (or a connection string to a remote MongoDB database)
- Git (Optional, for cloning the repository)
To get a local copy of the repository, open your terminal and run:
git clone [REPO_URL]
Replace [REPO_URL] with the URL of your Git repository.
Once cloned, navigate to the project directory:
cd [PROJECT_DIRECTORY_NAME]
Replace [PROJECT_DIRECTORY_NAME] with the name of the directory where your project is located.
Now, install all the necessary project dependencies using npm:
npm install
To configure the environment, create a .env file in the project's root directory. Add the necessary configurations:
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
JWT_EXP=set_jwt_expiry
Make sure to replace the placeholders with your actual values.
####6. Start the Development Server With everything set up, start the development server:
npm start
Your server should now be running at http://localhost:3000/ (or whatever port you specified in your .env).
This endpoint allows new users to register on the BlogApi platform by providing necessary details.
http://localhost:3000/app/v1/users/register
{
"username": "test2",
"email": "test2@gmail.com",
"password": "12345678",
"fullName": "Test User",
"profilePic": "https://example.com/profiles/john_doe.jpg"
}
{
"success": "true",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1MDZlOGMzN2RlNzJkNDFjYWJhMGVhYSIsImlhdCI6MTY5NDk1MTYyMCwiZXhwIjoxNjk1MjEwODIwfQ.cOxiaJWxKTsxrRpGrHXwBFXlkkC2EYT6IR056UrfvbI"
}
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
Allows users to log in to their accounts. On successful authentication, a token will be provided for further secure operations.
{{URL}}/app/v1/users/login
{
"email":"test@gmail.com",
"password":"12345678"
}
{
"success": "true",
"token": "<< TOKEN >>"
}
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
Authenticated users can use this endpoint to create a new blog post by providing the required details.
NOTE: You should be loged in for adding Blog
{{URL}}/app/v1/blogs
{
"title": "Demystifying GraphQL",
"author": "65063c16e680bfef2b2a2287", // This is a dummy ObjectId
"content": "GraphQL is a query language for APIs and a runtime for executing those queries with existing data. It offers a more efficient, powerful, and flexible alternative to REST...",
"tags": ["GraphQL", "API", "Query Language"]
}
Param | value | Type |
---|---|---|
token | << TOKEN >> | string |
{
"success": "true",
"data": {
"title": "Demystifying GraphQL",
"author": "6506489fa1d43eb809521bce",
"content": "GraphQL is a query language for APIs and a runtime for executing those queries with existing data. It offers a more efficient, powerful, and flexible alternative to REST...",
"tags": [
"GraphQL",
"API",
"Query Language"
],
"_id": "6506e8e57de72d41caba0ead",
"date": "2023-09-17T11:54:13.504Z",
"comments": [],
"__v": 0
}
}
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
This endpoint fetches a list of all blog posts present on the platform.
{{URL}}/app/v1/blogs
{
"success": "true",
"data": [
{
"_id": "65064c72f58576146bdba92b",
"title": "Introduction to Node.js (Update)",
"author": "65063c16e680bfef2b2a2287",
"content": "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows for the development of scalable network applications...",
"comments": [
{
"author": "65063c16e680bfef2b2a2287",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506d2763f9497f64e0893e3",
"date": "2023-09-17T10:18:30.775Z"
},
{
"author": "65063c16e680bfef2b2a2287",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506d4713f9497f64e0893e8",
"date": "2023-09-17T10:26:57.352Z"
},
{
"author": "6506489fa1d43eb809521bce",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506e1de3a4c1c19a0a7bac6",
"date": "2023-09-17T11:24:14.245Z"
}
],
"tags": [
"Node.js",
"JavaScript",
"Backend"
],
"date": "2023-09-17T00:46:42.873Z",
"__v": 0
},
{
"_id": "65064df61b4ca14553f609f5",
"title": "Deep Dive into MongoDB",
"author": "6506489fa1d43eb809521bce",
"content": "MongoDB is a NoSQL database that provides high performance, high availability, and easy scalability. It works on the concept of collections and documents...",
"tags": [
"MongoDB",
"Database",
"NoSQL"
],
"date": "2023-09-17T00:53:10.445Z",
"comments": [],
"__v": 0
},
{
"_id": "65064e181b4ca14553f609f7",
"title": "Demystifying GraphQL",
"author": "65063c16e680bfef2b2a2287",
"content": "GraphQL is a query language for APIs and a runtime for executing those queries with existing data. It offers a more efficient, powerful, and flexible alternative to REST...",
"tags": [
"GraphQL",
"API",
"Query Language"
],
"date": "2023-09-17T00:53:44.001Z",
"comments": [],
"__v": 0
},
{
"_id": "6506e8e57de72d41caba0ead",
"title": "Demystifying GraphQL",
"author": "6506489fa1d43eb809521bce",
"content": "GraphQL is a query language for APIs and a runtime for executing those queries with existing data. It offers a more efficient, powerful, and flexible alternative to REST...",
"tags": [
"GraphQL",
"API",
"Query Language"
],
"date": "2023-09-17T11:54:13.504Z",
"comments": [],
"__v": 0
}
]
}
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
Retrieves the complete details of a specific blog post identified by its unique ID.
{{URL}}/app/v1/blogs/65064c72f58576146bdba92b
Param | value | Type |
---|---|---|
token | << TOKEN >> | string |
{
"success": "true",
"data": {
"_id": "65064c72f58576146bdba92b",
"title": "Introduction to Node.js (Update)",
"author": "65063c16e680bfef2b2a2287",
"content": "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows for the development of scalable network applications...",
"comments": [
{
"author": "65063c16e680bfef2b2a2287",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506d2763f9497f64e0893e3",
"date": "2023-09-17T10:18:30.775Z"
},
{
"author": "65063c16e680bfef2b2a2287",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506d4713f9497f64e0893e8",
"date": "2023-09-17T10:26:57.352Z"
},
{
"author": "6506489fa1d43eb809521bce",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506e1de3a4c1c19a0a7bac6",
"date": "2023-09-17T11:24:14.245Z"
}
],
"tags": [
"Node.js",
"JavaScript",
"Backend"
],
"date": "2023-09-17T00:46:42.873Z",
"__v": 0
}
}
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
Allows the author to modify certain details of a blog post they have created. This endpoint expects an authenticated request.
NOTE: Only author can update or delete their blog
{{URL}}/app/v1/blogs/65064c72f58576146bdba92b
{
"title": "Introduction to Node.js (Update)"
}
Param | value | Type |
---|---|---|
token | << TOKEN >> | string |
{
"success": "true",
"data": {
"_id": "65064c72f58576146bdba92b",
"title": "Introduction to Node.js (Update)",
"author": "65063c16e680bfef2b2a2287",
"content": "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows for the development of scalable network applications...",
"comments": [
{
"author": "65063c16e680bfef2b2a2287",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506d2763f9497f64e0893e3",
"date": "2023-09-17T10:18:30.775Z"
},
{
"author": "65063c16e680bfef2b2a2287",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506d4713f9497f64e0893e8",
"date": "2023-09-17T10:26:57.352Z"
},
{
"author": "6506489fa1d43eb809521bce",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506e1de3a4c1c19a0a7bac6",
"date": "2023-09-17T11:24:14.245Z"
}
],
"tags": [
"Node.js",
"JavaScript",
"Backend"
],
"date": "2023-09-17T00:46:42.873Z",
"__v": 0
}
}
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
Allows the author to delete blog post they have created. This endpoint expects an authenticated request.
NOTE: Only author can update or delete their blog
{{URL}}/app/v1/blogs/65064ddd1b4ca14553f609f3
Param | value | Type |
---|---|---|
token | << TOKEN >> | string |
{
"success": "true",
"data": {
"_id": "65064ddd1b4ca14553f609f3",
"title": "Mastering Express.js",
"author": "6506489fa1d43eb809521bce",
"content": "Express.js is a minimal and flexible Node.js web application framework that provides robust tools for web and mobile applications...",
"tags": [
"Express.js",
"Web Development",
"Node.js"
],
"date": "2023-09-17T00:52:45.812Z",
"comments": [],
"__v": 0
}
}
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
Authenticated users can add comments to a specific blog post to engage in discussions or provide feedback.
NOTE: You should be loged In for writting the blog
{{URL}}/app/v1/blogs/65064c72f58576146bdba92b/comments
{
"text":"I found this very informative. Keep up the good work!"
}
Param | value | Type |
---|---|---|
token | << TOKEN >> | string |
{
"success": "true",
"data": {
"_id": "65064c72f58576146bdba92b",
"title": "Introduction to Node.js (Update)",
"author": "65063c16e680bfef2b2a2287",
"content": "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows for the development of scalable network applications...",
"comments": [
{
"author": "65063c16e680bfef2b2a2287",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506d2763f9497f64e0893e3",
"date": "2023-09-17T10:18:30.775Z"
},
{
"author": "65063c16e680bfef2b2a2287",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506d4713f9497f64e0893e8",
"date": "2023-09-17T10:26:57.352Z"
},
{
"author": "6506489fa1d43eb809521bce",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506e166f4ea561652039154",
"date": "2023-09-17T11:22:14.721Z"
},
{
"author": "6506489fa1d43eb809521bce",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506e1de3a4c1c19a0a7bac6",
"date": "2023-09-17T11:24:14.245Z"
}
],
"tags": [
"Node.js",
"JavaScript",
"Backend"
],
"date": "2023-09-17T00:46:42.873Z",
"__v": 0
}
}
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
StartFragmentllows the commenter or the blog's author to delete a comment. This operation requires authentication.EndFragment
NOTE: Comments are onle deleted by comment writter and Blog owner
{{URL}}/app/v1/blogs/65064c72f58576146bdba92b/comments/6506e166f4ea561652039154
Param | value | Type |
---|---|---|
token | << TOKEN >> | string |
{
"success": "true",
"data": {
"_id": "65064c72f58576146bdba92b",
"title": "Introduction to Node.js (Update)",
"author": "65063c16e680bfef2b2a2287",
"content": "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows for the development of scalable network applications...",
"comments": [
{
"author": "65063c16e680bfef2b2a2287",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506d2763f9497f64e0893e3",
"date": "2023-09-17T10:18:30.775Z"
},
{
"author": "65063c16e680bfef2b2a2287",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506d4713f9497f64e0893e8",
"date": "2023-09-17T10:26:57.352Z"
},
{
"author": "6506489fa1d43eb809521bce",
"text": "I found this very informative. Keep up the good work!",
"_id": "6506e1de3a4c1c19a0a7bac6",
"date": "2023-09-17T11:24:14.245Z"
}
],
"tags": [
"Node.js",
"JavaScript",
"Backend"
],
"date": "2023-09-17T00:46:42.873Z",
"__v": 0
}
}
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃