Skip to content

Commit

Permalink
Merge pull request #2 from BianorAraujo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
BianorAraujo authored Sep 19, 2020
2 parents 5faead9 + 9611083 commit 9461bab
Show file tree
Hide file tree
Showing 5 changed files with 360 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# node-backend-task

Backend repository for a Tasks application in NodeJs

Repositório do backend para uma aplicação de Tarefas em NodeJs


You can access the api here: [Tasks API - Node js](https://mobiletasks.herokuapp.com/api-docs)

337 changes: 337 additions & 0 deletions config/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
{
"openapi": "3.0.1",
"info": {
"version": "1.1.0",
"title": "Tasks API - Node js",
"description": "API for Tasks application",
"contact": {
"name": "Bianor Araujo",
"email": "[email protected]"
}
},
"servers": [
{
"url": "http://localhost:3000/",
"description": "Local server"
},
{
"url": "https://mobiletasks.herokuapp.com/",
"description": "Testing server"
}
],
"tags": [
{
"name": "Signup"
},
{
"name": "Signin"
},
{
"name": "Tasks"
}
],
"paths": {
"/signup": {
"post": {
"security": { },
"description": "Register a new user to be able to use the api",
"tags":[
"Signup"
],
"requestBody": {
"description":"A JSON object containing the properties below",
"required":"true",
"content":{
"application/json":{
"schema":{
"type":"object",
"required":[
"name",
"email",
"password"
],
"properties":{
"name":{
"type":"string"
},
"email":{
"type":"string"
},
"password":{
"type":"string"
}
},
"example": {
"name": "Joao",
"email": "[email protected]",
"password": "123!@#"
}
}
}
}
},
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type":"object",
"required":[
"name",
"email",
"token"
],
"properties":{
"name":{
"type":"string"
},
"email":{
"type":"string"
},
"token":{
"type":"string"
}
},
"example": {
"name": "Joao",
"email": "[email protected]",
"token": "ayJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6M30.4vWyUiu2Ry4heP8EZKBSt6ZDV3BSvxWLxZbC4YbE7b9"
}
}
}
}
}
}
}
},
"/signin": {
"post":{
"security": { },
"description": "Logs the user into the system and returns the access token",
"tags": [
"Signin"
],
"requestBody": {
"description":"A JSON object containing the properties below",
"required":"true",
"content":{
"application/json":{
"schema":{
"type":"object",
"required":[
"email",
"password"
],
"properties":{
"email":{
"type":"string"
},
"password":{
"type":"string"
}
},
"example": {
"email": "[email protected]",
"password": "123!@#"
}
}
}
}
},
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type":"object",
"required":[
"name",
"email",
"token"
],
"properties":{
"name":{
"type":"string"
},
"email":{
"type":"string"
},
"token":{
"type":"string"
}
},
"example": {
"name": "Joao",
"email": "[email protected]",
"token": "ayJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6M30.4vWyUiu2Ry4heP8EZKBSt6ZDV3BSvxWLxZbC4YbE7b9"
}
}
}
}
}
}
}
},
"/tasks": {
"get": {
"description": "Get tasks registered by a user",
"tags": [
"Tasks"
],
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type":"object",
"required":[
"id",
"desc",
"estimateAt",
"doneAt",
"userId"
],
"properties":{
"id":{
"type":"integer"
},
"desc":{
"type":"string"
},
"estimateAt":{
"type":"datetime"
},
"doneAt":{
"type":"datetime"
},
"userId":{
"type":"integer"
}
},
"example": {
"id": 7,
"desc": "Tarefa 1",
"estimateAt": "2020-08-26T03:00:00.000Z",
"doneAt": null,
"userId": 2
}
}
}
}
}
}
},
"post": {
"description": "Save your tasks",
"tags": [
"Tasks"
],
"requestBody": {
"description":"A JSON object containing the properties below",
"required":"true",
"content":{
"application/json":{
"schema":{
"type":"object",
"required":[
"desc",
"estimateAt"
],
"properties":{
"desc":{
"type":"string"
},
"estimateAt":{
"type":"string"
}
},
"example": {
"desc": "Tarefa 1",
"estimateAt": "2020-08-26"
}
}
}
}
},
"responses": {
"204": {
"description": "No Content",
"content": {
}
}
}
}
},
"/tasks/{id}/toggle": {
"put": {
"description": "Toggle a task between completed and not completed.",
"tags": [
"Tasks"
],
"parameters": [
{
"in": "path",
"name": "id",
"description": "Task id",
"required": true,
"schema": {
"type": "integer",
"default": 1
}
}
],
"responses": {
"204": {
"description": "No Content",
"content": {
}
}
}
}
},
"/tasks/{id}": {
"delete": {
"description": "Delete tasks registered by a user",
"tags": [
"Tasks"
],
"parameters": [
{
"in": "path",
"name": "id",
"description": "Task id",
"required": true,
"schema": {
"type": "integer",
"default": 1
}
}
],
"responses": {
"204": {
"description": "No Content",
"content": {
}
}
}
}
}
},
"components": {
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT"
}
}
},
"security": [
{
"bearerAuth": []
}
]
}
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const express = require('express')
const app = express()
const db = require('./config/db')
const consign = require('consign')
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./config/swagger.json');

const port = process.env.PORT || 3000

Expand All @@ -14,6 +16,8 @@ consign()

app.db = db

app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

app.listen(port , () => {
console.log('Backend executando...')
})
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"moment": "2.27.0",
"passport": "0.4.1",
"passport-jwt": "4.0.0",
"pg": "8.3.2"
"pg": "8.3.2",
"swagger-ui-express": "4.1.4"
},
"devDependencies": {
"nodemon": "2.0.4"
Expand Down

0 comments on commit 9461bab

Please sign in to comment.