This is a final year project facilitating api to all students of the any college to ask questions on the open forum platform.
We are trying to develop a web application that would be sort of Quora but specifically dedicated to college(s). The main problem we are trying to solve is that the juniors donβt know about their seniors or vise versa and they have no means of establishing communication with them. Thatβs when the application of our software comes into the picture. We have built centralized api which can be used by organisations directly into their portal to quickly facilitate faqβs and general questions.
/server
foldernpm start
or npm run start:dev
to start prod or dev environment as you likenpm start
or npm run start
to start prod or dev environment as you likedocker pull ghcr.io/kaiwalyakoparkar/quora-for-college-api:latest
/quora-for-college/server
directorydocker-compose up --build
. This will build and start the backend container with the databasedocker pull ghcr.io/kaiwalyakoparkar/quora-for-college:latest
/quora-for-college
directoryπ© 1. GET /api/v1/questions
Gets all the questions in the database. The typical response looks like
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/questions
And ideal response will look like
{
"status": "Success",
"result": 3,
"data": {
"questions": [
{
"_id": "61dd4b66875fa2ba15492c65",
"userQuestioner": "Kaiwalya Koparkar",
"questionTitle": "This is a question 1",
"questionDescription": "This is the description of the question",
"questionTag": "Courses",
"upvotes": 10,
"downvotes": 3,
"answers": [
"61dd46f03cecd228e9df643a",
"61dd46f03cecd228e9df6439"
],
"id": "61dd4b66875fa2ba15492c65"
},
.
.
.
]
}
}
π© 2. GET /api/v1/questions/<question id>
Gets specific question from large questions data. The question id here is given by the database.
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/questions/61dd4b66875fa2ba15492c65
And ideal response will look like
{
"status": "Success",
"data": {
"question": {
"_id": "61dd4b66875fa2ba15492c65",
"userQuestioner": "Kaiwalya Koparkar",
"questionTitle": "This is a question 1",
"questionDescription": "This is the description of the question",
"questionTag": "Courses",
"upvotes": 10,
"downvotes": 3,
"answers": [
"61dd46f03cecd228e9df643a",
"61dd46f03cecd228e9df6439"
],
"__v": 0,
"id": "61dd4b66875fa2ba15492c65"
}
}
}
π© 3. POST /api/v1/questions/
This routes helps the user to add questions to the database or application
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/questions
req.body π
{
"userQuestioner": "Test User",
"questionTitle": "This is a test question",
"questionDescription": "This is the description of the question",
"questionTag": "Sports"
}
And ideal response will look like
{
"status": "Success",
"data": {
"question": {
"userQuestioner": "Test User",
"questionTitle": "This is a test question",
"questionDescription": "This is the description of the question",
"questionTag": "Sports",
"upvotes": 0,
"downvotes": 0,
"answers": [],
"_id": "61e4278c7d95535e6005f327",
"__v": 0,
"id": "61e4278c7d95535e6005f327"
}
}
}
π© 4. PATCH /api/v1/questions/<question-id>
This routes helps the user to update question to the database or application
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/questions/61e4278c7d95535e6005f327
req.body π
{
"userQuestioner": "Test User (Changed)"
}
And ideal response will look like
{
"status": "Success",
"data": {
"question": {
"_id": "61e4278c7d95535e6005f327",
"userQuestioner": "Test User (Changed)",
"questionTitle": "This is a test question",
"questionDescription": "This is the description of the question",
"questionTag": "Sports",
"upvotes": 0,
"downvotes": 0,
"answers": [],
"__v": 0,
"id": "61e4278c7d95535e6005f327"
}
}
}
π© 5. PATCH /api/v1/questions/<question-id>
This routes helps the user to upvote a question to the database or application
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/questions/61e4278c7d95535e6005f327
req.body π
{
"upvotes": "0"
}
And ideal response will look like
{
"status": "Success",
"data": {
"question": {
"_id": "61e4278c7d95535e6005f327",
"userQuestioner": "Test User (Changed)",
"questionTitle": "This is a test question",
"questionDescription": "This is the description of the question",
"questionTag": "Sports",
"upvotes": 1,
"downvotes": 0,
"answers": [],
"__v": 0,
"id": "61e4278c7d95535e6005f327"
}
}
}
π© 6. PATCH /api/v1/questions/<question-id>
This routes helps the user to upvote a question to the database or application
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/questions/61e4278c7d95535e6005f327
req.body π
{
"downvotes": "0"
}
And ideal response will look like
{
"status": "Success",
"data": {
"question": {
"_id": "61e4278c7d95535e6005f327",
"userQuestioner": "Test User (Changed)",
"questionTitle": "This is a test question",
"questionDescription": "This is the description of the question",
"questionTag": "Sports",
"upvotes": 1,
"downvotes": 1,
"answers": [],
"__v": 0,
"id": "61e4278c7d95535e6005f327"
}
}
}
π© 7. DELETE /api/v1/questions/<question-id>
This routes helps the user to upvote a question to the database or application
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/questions/61e4278c7d95535e6005f327
And ideal response will look like
{
"status": "Success",
"data": {
"question": {
"_id": "61e4278c7d95535e6005f327",
"userQuestioner": "Test User (Changed)",
"questionTitle": "This is a test question",
"questionDescription": "This is the description of the question",
"questionTag": "Sports",
"upvotes": 1,
"downvotes": 0,
"answers": [],
"__v": 0,
"id": "61e4278c7d95535e6005f327"
}
}
}
π© 1. GET /api/v1/answers
Gets all the answers in the database. The typical response looks like
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/answers
And ideal response will look like
{
"status": "Success",
"result": 3,
"data": {
"answers": [
{
"_id": "61dd46f03cecd228e9df643a",
"userAnswerer": "Mrunaal Chincholikar",
"answer": "This is the answer 2",
"upvotes": 24,
"downvotes": 1,
"id": "61dd46f03cecd228e9df643a"
},
.
.
.
]
}
}
π© 2. GET /api/v1/answers/<answer id>
Gets specific answer from large answers data. The answer id here is given by the database.
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/answers/61dd46f03cecd228e9df643a
And ideal response will look like
{
"status": "Success",
"data": {
"answer": {
"_id": "61dd46f03cecd228e9df643a",
"userAnswerer": "Mrunaal Chincholikar",
"answer": "This is the answer 2",
"upvotes": 24,
"downvotes": 1,
"__v": 0,
"id": "61dd46f03cecd228e9df643a"
}
}
}
π© 3. POST /api/v1/answers/<question-id>
This routes helps the user to add answers to the database or application for the specific question provided in params
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/answers/61dd4b66875fa2ba15492c65
req.body π
{
"userAnswerer": "Test",
"answer": "This is the test answer 2"
}
And ideal response will look like (Also the question will have record of this answer)
{
"status": "Success",
"data": {
"answer": {
"userAnswerer": "Test",
"answer": "This is the test answer 2",
"upvotes": 0,
"downvotes": 0,
"_id": "61e42adf7d95535e6005f33b",
"__v": 0,
"id": "61e42adf7d95535e6005f33b"
}
}
}
π© 4. PATCH /api/v1/answers/<answer-id>
This routes helps the user to update answer to the database or application
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/answers/61e42adf7d95535e6005f33b
req.body π
{
"userAnswerer": "Test User (Changed)"
}
And ideal response will look like
{
"status": "Success",
"data": {
"answer": {
"_id": "61e42adf7d95535e6005f33b",
"userAnswerer": "Test User (Changed)",
"answer": "This is the test answer 2",
"upvotes": 0,
"downvotes": 0,
"__v": 0,
"id": "61e42adf7d95535e6005f33b"
}
}
}
π© 5. PATCH /api/v1/answers/<answer-id>
This routes helps the user to upvote a answer to the database or application
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/answers/61e42adf7d95535e6005f33b
req.body π
{
"upvotes": "0"
}
And ideal response will look like
{
"status": "Success",
"data": {
"answer": {
"_id": "61e42adf7d95535e6005f33b",
"userAnswerer": "Test User (Changed)",
"answer": "This is the test answer 2",
"upvotes": 1,
"downvotes": 0,
"__v": 0,
"id": "61e42adf7d95535e6005f33b"
}
}
}
π© 6. PATCH /api/v1/answers/<answer-id>
This routes helps the user to upvote an answer to the database or application
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/answers/61e4278c7d95535e6005f327
req.body π
{
"downvotes": "0"
}
And ideal response will look like
{
"status": "Success",
"data": {
"answer": {
"_id": "61e42adf7d95535e6005f33b",
"userAnswerer": "Test User (Changed)",
"answer": "This is the test answer 2",
"upvotes": 1,
"downvotes": 1,
"__v": 0,
"id": "61e42adf7d95535e6005f33b"
}
}
}
π© 7. DELETE /api/v1/answers/<answer-id>
This routes helps the user to upvote a answer to the database or application also it will delete itβs record from concerned question document
Example 1:
An ideal request will look like
http://localhost:8080/api/v1/answers/61e4278c7d95535e6005f327
And ideal response will look like
{
"status": "Success",
"data": {
"answer": {
"_id": "61e42adf7d95535e6005f33b",
"userAnswerer": "Test User (Changed)",
"answer": "This is the test answer 2",
"upvotes": 1,
"downvotes": 1,
"__v": 0,
"id": "61e42adf7d95535e6005f33b"
}
}
}
π© 1. POST /api/v1/users/login
This routes helps the user to log in to the application
Example
An ideal request will look like
http://localhost:8080/api/v1/users/login
req.body π
{
"email": "[email protected]",
"password": "This is password"
}
And ideal response will look like
{
"status": "success",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZTE4Y2FmYWYzYWYyMjY1ZTY1M2JlNSIsImlhdCI6MTY0MjM0NDE4MywiZXhwIjoxNjUwMTIwMTgzfQ.rxHCh2b4gmGegFeuLJktrxnQ5MxsbOh5jEXKTovooxg",
"data": {
"user": {
"_id": "61e18cafaf3af2265e653be5",
"name": "Student User",
"email": "[email protected]",
"yearOfAdmission": 2019,
"courseYear": "TY",
"currentStatus": "Student",
"role": "Student",
"questionsAsked": [],
"questionsAnswered": 2,
"active": "true",
"__v": 0,
"about": "I am a Computer Engineering Student"
}
}
}
π© 2. POST /api/v1/users/signup
This routes helps the new user to sign in to the application
Example
An ideal request will look like
http://localhost:8080/api/v1/users/signup
req.body π
{
"name" : "Test User",
"email" : "[email protected]",
"password" : "This is password",
"passwordConfirm" : "This is password",
"yearOfAdmission": 2017,
"courseYear": "Prof",
"currentStatus": "Professor"
}
And ideal response will look like
{
"status": "success",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZTQyZjM5N2Q5NTUzNWU2MDA1ZjM0OSIsImlhdCI6MTY0MjM0NDI0OSwiZXhwIjoxNjUwMTIwMjQ5fQ.vSffyAezxOCPJjkFbvMktPbgd9kk_3AB3h9VkGY4t3M",
"data": {
"user": {
"name": "Test User",
"email": "[email protected]",
"yearOfAdmission": 2017,
"courseYear": "Prof",
"currentStatus": "Professor",
"role": "Student",
"questionsAsked": [],
"questionsAnswered": 0,
"active": "true",
"_id": "61e42f397d95535e6005f349",
"__v": 0
}
}
}
π© 3. GET /api/v1/users/logout
This routes helps the user to log out of the application
Example
An ideal request will look like
http://localhost:8080/api/v1/users/logout
And ideal response will look like
{
"status": "Success"
}
π© 4. GET /api/v1/users/
(Admin role only)
This routes helps the admin user to get the information about all the users using the application
Example 1 (Admin success)
An ideal request will look like
http://localhost:8080/api/v1/users/
And ideal response will look like
{
"status": "success",
"result": 4,
"requestedAt": "2022-01-16T14:44:58.323Z",
"data": {
"users": [
{
"_id": "61e18cafaf3af2265e653be5",
"name": "Student User",
"email": "[email protected]",
"yearOfAdmission": 2019,
"courseYear": "TY",
"currentStatus": "Student",
"role": "Student",
"questionsAsked": [],
"questionsAnswered": 2,
"password": "$2a$04$kzpaXwihpuvL2FV5YjMHe.gJAMVA5VVEVcyqGHYnJtPpDLRy41ndy",
"active": "true",
"about": "I am a Computer Engineering Student"
},
.
.
.
]
}
}
Example 2 (Regular user failure)
An ideal request will look like
http://localhost:8080/api/v1/users/
And ideal response will look like
{
"status": "fail",
"message": "You do not have permission to perform this action"
}
π© 5. GET /api/v1/users/me
This routes helps the logged in user to get information about self
Example
An ideal request will look like
http://localhost:8080/api/v1/users/me
And ideal response will look like
{
"status": "success",
"requestedAt": "2022-01-16T14:46:38.984Z",
"data": {
"user": {
"_id": "61e18cafaf3af2265e653be5",
"name": "Student User",
"email": "[email protected]",
"yearOfAdmission": 2019,
"courseYear": "TY",
"currentStatus": "Student",
"role": "Student",
"questionsAsked": [],
"questionsAnswered": 2,
"password": "$2a$04$kzpaXwihpuvL2FV5YjMHe.gJAMVA5VVEVcyqGHYnJtPpDLRy41ndy",
"active": "true",
"__v": 0,
"about": "I am a Computer Engineering Student"
}
}
}
π© 6. PATCH /api/v1/users/updateMe
This routes helps the logged in user to update the information about self
Example
An ideal request will look like
http://localhost:8080/api/v1/users/updateMe
req.body π
{
"about": "I am a Test Computer Engineering Student"
}
And ideal response will look like
{
"status": "success",
"data": {
"user": {
"_id": "61e42f397d95535e6005f349",
"name": "Test User",
"email": "[email protected]",
"yearOfAdmission": 2017,
"courseYear": "Prof",
"currentStatus": "Professor",
"role": "Student",
"questionsAsked": [],
"questionsAnswered": 0,
"password": "$2a$04$WZeORcAk6Bxj.gcs4PqfTeBLUzJiCgkGHgmNWS16d8nyuSvt81XsS",
"active": "true",
"__v": 0,
"about": "I am a Test Computer Engineering Student"
}
}
}
π© 7. DELETE /api/v1/users/deleteMe
This routes helps the logged in user to delete/deactivate their account
Example
An ideal request will look like
http://localhost:8080/api/v1/users/deleteMe
And ideal response will look like
null
If you would like to contribute to this api please go ahead and read COC and Contributing Guideline. Once you read through them agree to policies of this question go ahead with question setup & Contribution steps below
Fork the question
Once you are in your fork the url should look something like
https://github.com/<YOUR-USERNAME>/quora-for-college/
Go to preferred folder in your computer and paste the following command (Only one of it if you donβt have ssh setup then go with HTTP command)
git clone https://github.com/<YOUR-USERNAME>/quora-for-college.git
git clone [email protected]:<YOUR-USERNAME>/quora-for-college.git
Now enter the folder by running the following command
cd quora-for-college/server
Now you are in the /server
folder
Now do ahead and create a new branch and move to the branch
git checkout -b fix-issue-<ISSUE-NUMBER>
Now run npm i
and once itβs done do your fixes and changes.
After done you can now push this changes. for doing that follow the following command chain
git status
(Shows the changed files)git add .
(Will add all the files to staging area)git commit -m "feat/docs/fix: :emoji-name: <EXPLAIN-YOUR_CHANGES>"
git push origin fix-issue-<ISSUE-NUMBER>
After this go to your forked GitHub repository and go to Pull Request
section. Now you might be able to see a pop up saying Pull Request. Click on the popup and you will be redirected to pull request page
Now fill in the form template of the pull request
Click on Submit
Hurray! You just did your contribution to this question π