This project is a simple implementation of the basic features of StackOverflow. It was developed using the stack below, and managed with Pivotal Tracker
- Server: NodeJS, Express
- Database: MongoDB (with Mongoose ORM)
- Base Application: https://osaukhu-stack-overflow.herokuapp.com/
- Version 1 API: https://osaukhu-stack-overflow.herokuapp.com/api/v1
- Pivotal Tracker Board: https://www.pivotaltracker.com/projects/2402465
- OpenAPI Documentation: https://osaukhu-stack-overflow.herokuapp.com/docs
- Signup
- Login
- Ask Questions
- View Questions
- Upvote or Downvote a question
- Answer Question
- Search (Questions, Answers, Users)
- Clone the repo
- Ensure you set up environment variables based on the .env.sample file
- Run the following commands
npm install
npm run start:dev
POST /api/v1/auth/signup
- required: displayName, email, password
{
"displayName": "john123",
"email": "[email protected]",
"password": "john1234",
}
{
"message": "sucessfully created user!",
"data": {
"id": "5d9e17a86ad68437fc740109",
"email": "[email protected]",
"displayName": "john123",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkOWUxN2E4NmFkNjg0MzdmYzc0MDEwOSIsImlhdCI6MTU3MDY0MjA3NCwiZXhwIjoxNTcwNzI4NDc0fQ.itSBwRRaN22OWzzToBoSP-u1HbhIeYUcmWQzLjeFafk"
}
}
POST /api/v1/auth/login
- required: email, password
{
"email": "[email protected]",
"password": "john1234",
}
{
"message": "login successful",
"data": {
"id": "5d9e17a86ad68437fc740109",
"email": "[email protected]",
"displayName": "john123",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkOWUxN2E4NmFkNjg0MzdmYzc0MDEwOSIsImlhdCI6MTU3MDY0MjA3NCwiZXhwIjoxNTcwNzI4NDc0fQ.itSBwRRaN22OWzzToBoSP-u1HbhIeYUcmWQzLjeFafk"
}
}
POST /api/v1/questions
- required: title, body, authorization(in header)
- optional: tags
{
"title": "Javascript or python, which is better",
"body": "I want to know the better of javascript and python",
"tags": ["javascript", "python"]
}
{
"message": "successfully asked a question!",
"data": {
"tags": [
"javascript",
"python"
],
"answers": [],
"_id": "5d9e19bf6ad68437fc74010a",
"owner": "5d9e17a86ad68437fc740109",
"title": "Javascript or python, which is better",
"body": "I want to know the better of javascript and python",
"votes": [],
"updatedAt": "2019-10-09T17:32:47.734Z",
"createdAt": "2019-10-09T17:32:47.734Z",
"__v": 0
}
}
GET /api/v1/questions
- required: authorization(in header)
- optional: page (defaults to 1), limit (defaults to 20)
{
"message": "succesfully returned questions",
"currentPage": 1,
"totalPages": 1,
"limit": 20,
"data": [
{
"id": "5d9e19bf6ad68437fc74010a",
"owner": "john123",
"title": "Javascript or python, which is better",
"body": "I want to know the better of javascript and python",
"tags": [
"javascript",
"python"
],
"answers": [],
"upvotes": 0,
"downvotes": 0,
"createdAt": "2019-10-09T17:32:47.734Z",
"updatedAt": "2019-10-09T17:32:47.734Z"
}
]
}
GET /api/v1/questions/:questionId
- required: authorization(in header)
- where: questionId = 5d9a5867e0c2622f2805848f
{
"message": "successfully returned question",
"data": [
{
"id": "5d9e19bf6ad68437fc74010a",
"title": "Javascript or python, which is bettere",
"body": "I want to know the better of javascript and python",
"tags": [
"javascript",
"python"
],
"answers": [],
"upvotes": 0,
"downvotes": 0,
"createdAt": "2019-10-09T17:32:47.734Z",
"updatedAt": "2019-10-09T17:32:47.734Z"
}
]
}
PATCH /api/v1/questions/:questionId/vote
- required: voteType (in query), authorization(in header)
- where: questionId = 5d9a5867e0c2622f2805848f, voteType = up
{
"message": "you have successfully upvoted this question"
}
POST /api/v1/questions/:questionId/answers
- required: body, authorization(in header)
- where: questionId = 5d9a5867e0c2622f2805848f
{
"body": "both are very good"
}
{
"message": "successfully answered a question!",
"data": {
"_id": "5d9e1ea06ad68437fc74010c",
"owner": "5d9e17a86ad68437fc740109",
"body": "both are very good",
"updatedAt": "2019-10-09T17:53:36.750Z",
"createdAt": "2019-10-09T17:53:36.750Z",
"__v": 0
}
}
GET /api/v1/search
- required: type (in query), value (in query), authorization(in header)
- where: type = questions, value = python
{
"message": "successfully returned questions",
"data": [
{
"id": "5d9e19bf6ad68437fc74010a",
"owner": "john123",
"title": "Javascript or python, which is bettere",
"body": "I want to know the better of javascript and python",
"tags": [
"javascript",
"python"
],
"answers": [
{
"body": "both a very good",
"createdAt": "2019-10-09T17:53:36.750Z"
}
],
"upvotes": 1,
"downvotes": 0,
"createdAt": "2019-10-09T17:32:47.734Z",
"updatedAt": "2019-10-09T17:53:36.753Z"
}
]
}
Contributions are welcome, kindly clone the repo, create a new branch and raise a Pull Request