This API documentation provides details about the endpoints or routes of the application.
To run the Express app with npm start, follow these instructions:
-
Make sure you have Node.js and npm installed on your machine.
-
Open a terminal or command prompt.
-
Navigate to the root directory of your Express app project.
-
Run the following command to install the required dependencies:
npm install
-
Once the installation is complete, you can start the Express app by running the following:
npm start
-
After running npm start, the Express app should start and listen for incoming requests on the specified port (usually port 3000 by default). You should see a message in the terminal indicating that the app is running.
- GET /profiles/profile/:id
- POST /profiles/create_profile
- GET /api/comments
- GET /api/comments/recent
- GET /api/comments/most-likes
- POST /api/comments/create
- GET /api/comments/detail/:id
- POST /api/comments/like
- POST /api/comments/unlike
Retrieve a profile by its ID and render the profile page.
GET /profile/:id
id
(required): The ID of the profile.
- 200 OK: Profile successfully fetched and profile page rendered.
- 400 Bad Request: Invalid profile ID.
- 404 Not Found: Profile not found.
- 500 Internal Server Error: Failed to fetch profile.
The response renders the profile page with the retrieved profile details.
GET /profile/64b1473ce1e973d1265c7a5d
Create a new profile.
POST /api/profiles/create_profile
name
(required): The name of the profile.description
(required): The description of the profile.mbti
(required): The Myers-Briggs Type Indicator of the profile.enneagram
(required): The Enneagram type of the profile.variant
(required): The Enneagram variant of the profile.tritype
(required): The Enneagram tritype of the profile.socionics
(required): The Socionics type of the profile.sloan
(required): The Sloan type of the profile.psyche
(required): The psychological function of the profile.temperaments
(required): The temperaments of the profile.image
(required): The URL of the profile image.
- 201 Created: Profile successfully created.
- 400 Bad Request: Failed to create profile.
POST /api/profiles/create_profile
Content-Type: application/json
{
"name": "John Doe",
"description": "Lorem ipsum dolor sit amet",
"mbti": "INTJ",
"enneagram": "5w6",
"variant": "Social",
"tritype": "531",
"socionics": "ILE",
"sloan": "RLOAI",
"psyche": "Introverted Thinking",
"temperaments": "NT",
"image": "https://placebeard.it/640x360"
}
This API documentation provides details about the endpoints available for managing comments.
Retrieve comments based on the specified query type.
GET /comments
q
(required): The type of query ("mbti", "enneagram", or "zodiac").
- 200 OK: Comments successfully fetched based on the query type.
- 400 Bad Request: Invalid query type.
- 500 Internal Server Error: Failed to fetch comments.
GET /comments?q=mbti
[
{
"_id": "60db60c85c4c1c001f5279b2",
"userId": "123",
"mbti": "INTJ",
"description": "Comment 1",
"title": "Title 1",
"profileId": "60db60c85c4c1c001f5279b2",
"createdAt": "2021-07-01T12:34:56.789Z",
"updatedAt": "2021-07-02T09:12:34.567Z"
},
{
"_id": "60db60c85c4c1c001f5279b3",
"userId": "456",
"mbti": "INFJ",
"description": "Comment 2",
"title": "Title 2",
"profileId": "60db60c85c4c1c001f5279b3",
"createdAt": "2021-07-03T10:20:30.456Z",
"updatedAt": "2021-07-04T15:16:17.234Z"
}
]
Retrieve recent comments with pagination.
GET /api/comments/recent
`
page (optional): The page number for pagination. Defaults to 1. limit (optional): The number of comments per page. Defaults to 10.
200 OK: Recent comments successfully fetched. 500 Internal Server Error: Failed to fetch comments.
GET /api/comments/recent?page=1&limit=10
[
{
"_id": "60db60c85c4c1c001f5279b2",
"userId": "123",
"mbti": "INTJ",
"description": "Comment 1",
"title": "Title 1",
"profileId": "60db60c85c4c1c001f5279b2",
"createdAt": "2021-07-01T12:34:56.789Z",
"updatedAt": "2021-07-02T09:12:34.567Z"
},
{
"_id": "60db60c85c4c1c001f5279b3",
"userId": "456",
"mbti": "INFJ",
"description": "Comment 2",
"title": "Title 2",
"profileId": "60db60c85c4c1c001f5279b3",
"createdAt": "2021-07-03T10:20:30.456Z",
"updatedAt": "2021-07-04T15:16:17.234Z"
}
]
Retrieve comments with the most number of likes.
GET /api/comments/most-likes
page (optional): The page number for pagination. Defaults to 1. limit (optional): The number of comments per page. Defaults to 10.
200 OK: Comments with the most number of likes successfully fetched. 500 Internal Server Error: Failed to fetch comments.
GET /api/comments/most-likes?page=1&limit=10
[
{
"_id": "60db60c85c4c1c001f5279b2",
"userId": "123",
"mbti": "INTJ",
"description": "Comment 1",
"title": "Title 1",
"profileId": "60db60c85c4c1c001f5279b2",
"createdAt": "2021-07-01T12:34:56.789Z",
"updatedAt": "2021-07-02T09:12:34.567Z"
},
{
"_id": "60db60c85c4c1c001f5279b3",
"userId": "456",
"mbti": "INFJ",
"description": "Comment 2",
"title": "Title 2",
"profileId": "60db60c85c4c1c001f5279b3",
"createdAt": "2021-07-03T10:20:30.456Z",
"updatedAt": "2021-07-04T15:16:17.234Z"
}
]
Create a new comment.
POST /api/comments/create
- userId (required): The ID of the user creating the comment.
- mbti (optional): The MBTI type associated with the comment.
- enneagram (optional): The Enneagram type associated with the comment.
- zodiac (optional): The Zodiac sign associated with the comment.
- description (required): The description of the comment.
- title (required): The title of the comment.
- profileId (required): The ID of the associated profile.
- 201 Created: Comment successfully created.
- 400 Bad Request: Profile not found or failed to create comment.
POST /api/comments/create
Content-Type: application/json
{
"userId": "123",
"mbti": "INTJ",
"description": "Comment 1",
"title": "Title 1",
"profileId": "60db60c85c4c1c001f5279b2"
}
{
"_id": "60db60c85c4c1c001f5279b2",
"userId": "123",
"mbti": "INTJ",
"description": "Comment 1",
"title": "Title 1",
"profileId": "60db60c85c4c1c001f5279b2",
"createdAt": "2021-07-01T12:34:56.789Z",
"updatedAt": "2021-07-02T09:12:34.567Z"
}
Like a comment.
POST /api/comments/like
commentId
(required): The ID of the comment to like.userId
(required): The ID of the user liking the comment.
- 200 OK: Comment liked successfully.
- 400 Bad Request: User has already liked the comment.
- 500 Internal Server Error: Failed to like the comment.
POST /api/comments/like
Content-Type: application/json
{
"commentId": "60db60c85c4c1c001f5279b2",
"userId": "123"
}
Unlike a comment.
POST /api/comments/unlike
commentId
(required): The ID of the comment to unlike.userId
(required): The ID of the user unliking the comment.
- 200 OK: Comment unliked successfully.
- 500 Internal Server Error: Failed to unlike the comment.
POST /api/comments/unlike
Content-Type: application/json
{
"commentId": "60db60c85c4c1c001f5279b2",
"userId": "123"
}
{
"message": "Comment unliked successfully"
}