Deployment : Link
- Node.js
- Express.js
- MongoDB
- Mongoose
- GraphQL
- Apollo Server
- Clone the repository.
- Navigate to the backend directory.
- Run
npm install
to install dependencies. - Create
.env
and fill in the necessary environment variables. - Run
npm run start
to start the development server.
API's are built with graphQL
๐ข Get All Posts:
query {
getPosts {
id
body
createdAt
username
likeCount
commentCount
}
}
๐ข Get a Specific Post by ID:
query {
getPost(postId: "post_id_here") {
id
body
createdAt
username
likeCount
commentCount
}
}
๐ User Registration:
mutation {
register(registerInput: { username: "example_user", email: "[email protected]", password: "password123", confirmPassword: "password123" }) {
id
email
username
createdAt
token
}
}
๐ User Login:
mutation {
login(username: "example_user", password: "password123") {
id
email
username
createdAt
token
}
}
๐ Create a Post:
mutation {
createPost(body: "This is a test post") {
id
body
createdAt
username
}
}
๐ Create a Comment on a Post:
mutation {
createComment(postId: "post_id_here", body: "This is a test comment") {
id
comments {
id
body
createdAt
username
}
}
}
๐ Delete a Post (Requires authentication):
mutation {
deletePost(postId: "post_id_here")
}
๐ Like a Post (Requires authentication):
mutation {
likePost(postId: "post_id_here") {
id
likeCount
}
}
๐ Update a Post (Requires authentication):
mutation {
updatePost(postId: "post_id_here", body: "Updated post body") {
id
body
createdAt
username
}
}
๐ Delete a Comment
mutation {
deleteComment(postId: "post_id_here", commentId: "comment_id_here") {
id
comments {
id
body
createdAt
username
}
}
}
Note: Requires authentication for all types of mutations