Skip to content

cgabrieu/full-stack-overflow-developer-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Full Stack OverFlow Developer API 📚


About

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.


Technologies

Tools that were used in the project:

For more see the package.json


How It Works

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:

Make a POST /users:

{
  "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:

Make a POST /questions:

{
  "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:

Make a POST /questions:QUESTION_ID :

{
  "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


Getting Started

To run locally follow the steps

Prerequisites

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

Installation

  1. Create the root folder named full-stack-overflow-developer and access it
mkdir full-stack-overflow-developer && cd full-stack-overflow-developer
  1. Clone the repo
git clone https://github.com/cgabrieu/full-stack-overflow-developer-api.git
  1. Install dependencies with npm
npm install
  1. Create a database using the command below via postgres
CREATE DATABASE fullstackoverflow;
  1. Automatically create all necessary tables to backend repo with dump.

  2. Connect your backend to the database, for that, rename the .env.example to .env.dev and fill in your data.

How to run

  1. Run using the command (remember to be on the repo):
npm run start:dev

How to contribute

  1. Fork the project.
  2. Create a new branch with your changes: git checkout -b feat/myFeatureName
  3. For each feature implemented, make a commit specifying what was done
  4. Submit your changes: git push -u origin feat/myFeatureName

Developer

Releases

No releases published

Packages

No packages published