In this API people can post and answer questions. You can register, view the answered and unanswered questions, send an answer and access a ranking with the users who have the most answer points.
Tools that were used in the project:
For more see the package.json
See sample requests and responses
-
See all unanswered questions here (GET /questions)
-
See the answers to a specific question here (GET /questions/QUESTION_ID), when not answered here
-
See the ranking by points here
-
To answer a question you need to create a user to get your authorization token:
{
"name": "Marcio",
"class": "T3"
}
It will return a json web token:
{
"token": "xxxxx.yyyyy.zzzzz"
}
- If you create a question with an uncreated user, it will also return an authentication token:
{
"question": "Quando se deve usar 'var' no JavaScript?",
"student": "João Pedro",
"class": "T2",
"tags": "javascript, var"
}
It will return the question id and user authentication token:
{
"questionId": 2,
"userToken": "xxxxx.yyyyy.zzzzz"
}
- To answer a question:
{
"answer": "É um mecanismo de controle de fluxo que visa beneficiar processos assíncronos."
}
It will return status code 200 created. Make sure you're sending a header in the format:
BEARER xxxxx.yyyyy.zzzzz
-
To up vote a question (increase one point), make a PUT /questions/QUESTION_ID/up-vote
-
To down vote a question (decrease one point), make a PUT /questions/QUESTION_ID/down-vote
To run locally follow the steps
This is an example of how to list things you need to use the software and how to install them.
- npm
npm install npm@latest -g
- Create the root folder named full-stack-overflow-developer and access it
mkdir full-stack-overflow-developer && cd full-stack-overflow-developer
- Clone the repo
git clone https://github.com/cgabrieu/full-stack-overflow-developer-api.git
- Install dependencies with npm
npm install
- Create a database using the command below via postgres
CREATE DATABASE fullstackoverflow;
-
Automatically create all necessary tables to backend repo with dump.
-
Connect your backend to the database, for that, rename the .env.example to .env.dev and fill in your data.
- Run using the command (remember to be on the repo):
npm run start:dev
- Fork the project.
- Create a new branch with your changes:
git checkout -b feat/myFeatureName
- For each feature implemented, make a commit specifying what was done
- Submit your changes:
git push -u origin feat/myFeatureName