Skip to content

A Go API made for studies that manages tasks with user authentication

Notifications You must be signed in to change notification settings

samuelorlato/task-manager-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Manager API

A Go API made for studies that manages tasks with user authentication

Routes

Users

POST /register (registers new user)
JSON Body Params
name type data type
email required string (valid email)
password required string
Responses
http code content-type response
201 application/json {"ok":"use /login to authenticate"}
400 application/json {"description":"Validation error","error":"Key: 'User.Email' Error:Field validation for 'Email' failed on the 'email' tag"}
400 application/json {"description":"Validation error","error":"Key: 'UserDTO.Email' Error:Field validation for 'Email' failed on the 'required' tag"}
400 application/json {"description":"Validation error","error":"Key: 'UserDTO.Password' Error:Field validation for 'Password' failed on the 'required' tag"}
POST /login (logs in user)
JSON Body Params
name type data type
email required string
password required string
Responses
http code content-type response
200 application/json {"token":"..."}
400 application/json {"description":"Validation error","error":"Key: 'UserDTO.Email' Error:Field validation for 'Email' failed on the 'required' tag"}
400 application/json {"description":"Validation error","error":"Key: 'UserDTO.Password' Error:Field validation for 'Password' failed on the 'required' tag"}
400 application/json {"description":"Validation error","error":"crypto/bcrypt: hashedPassword is not the hash of the given password"}
500 application/json {"description":"Repository error","error":"User not found"}
PATCH /user (updates user's properties)
JSON Body Params
name type data type
email optional string
password optional string
Headers
name data type
Authorization string (JWT token)
Responses

| http code | content-type | response | | --------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------- | --- | --- | | 200 | application/json | {"status":"success"} | | 400 | application/json | {"description":"Validation error","error":"Key: 'User.Email' Error:Field validation for 'Email' failed on the 'email' tag"} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token is malformed: ..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"Authorization header not found"} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token has invalid claims: token is expired"} | | |

DELETE /user (deletes user)
Headers
name data type
Authorization string (JWT token)
Responses

| http code | content-type | response | | --------- | ------------------ | -------------------------------------------------------------------------------------------------- | --- | --- | | 200 | application/json | {"status":"success"} | | 401 | application/json | {"description":"You must be authenticated","error":"token is malformed: ..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"Authorization header not found"} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token has invalid claims: token is expired"} | | |

Tasks

GET /tasks (gets all authenticated user's tasks)
Headers
name data type
Authorization string (JWT token)
Responses

| http code | content-type | response | | --------- | ------------------ | -------------------------------------------------------------------------------------------------- | --- | --- | | 200 | application/json | [{...}] | | 401 | application/json | {"description":"You must be authenticated","error":"token is malformed: ..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"Authorization header not found"} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token has invalid claims: token is expired"} | | |

GET /tasks/:id (gets a task in authenticated user's tasks)
Headers
name data type
Authorization string (JWT token)
Responses

| http code | content-type | response | | --------- | ------------------ | -------------------------------------------------------------------------------------------------- | --- | --- | | 200 | application/json | {...} | | | | 400 | application/json | {"description":"Validation error","error":"invalid UUID length: ..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token is malformed: ..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"Authorization header not found"} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token has invalid claims: token is expired"} | | | | 500 | application/json | {"description":"Repository error","error":"Task not found"} |

POST /tasks (creates a task in authenticated user's tasks list)
JSON Body Params
name type data type
title required string
description optional string
toDate required string (dd/mm/yy hh:mm)
tags optional []string
Headers
name data type
Authorization string (JWT token)
Responses

| http code | content-type | response | | --------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | --- | --- | | 201 | application/json | {"createdTaskId":"..."} | | 400 | application/json | {"description":"Validation error","error":"Key: 'CreateTaskDTO.Title' Error:Field validation for 'Title' failed on the 'required' tag"} | | | | 400 | application/json | {"description":"Validation error","error":"Key: 'CreateTaskDTO.ToDate' Error:Field validation for 'ToDate' failed on the 'required' tag"} | | | | 400 | application/json | {"description":"Validation error","error":"parsing time..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token is malformed: ..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"Authorization header not found"} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token has invalid claims: token is expired"} | | |

PATCH /tasks/:id (updates a task in authenticated user's tasks list)
JSON Body Params
name type data type
title optional string
description optional string
toDate optional string (dd/mm/yy hh:mm)
completed optional bool
tags optional []string
Headers
name data type
Authorization string (JWT token)
Responses

| http code | content-type | response | | --------- | ------------------ | -------------------------------------------------------------------------------------------------- | --- | --- | | 200 | application/json | {"status":"success"} | | 400 | application/json | {"description":"Validation error","error":"parsing time..."} | | | | 400 | application/json | {"description":"Validation error","error":"invalid UUID length: ..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token is malformed: ..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"Authorization header not found"} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token has invalid claims: token is expired"} | | | | 500 | application/json | {"description":"Repository error","error":"Task not found"} |

DELETE /tasks/:id (deletes a task in authenticated user's tasks list)
Headers
name data type
Authorization string (JWT token)
Responses

| http code | content-type | response | | --------- | ------------------ | -------------------------------------------------------------------------------------------------- | --- | --- | | 200 | application/json | {"status":"success"} | | 400 | application/json | {"description":"Validation error","error":"parsing time..."} | | | | 400 | application/json | {"description":"Validation error","error":"invalid UUID length: ..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token is malformed: ..."} | | | | 401 | application/json | {"description":"You must be authenticated","error":"Authorization header not found"} | | | | 401 | application/json | {"description":"You must be authenticated","error":"token has invalid claims: token is expired"} | | | | 500 | application/json | {"description":"Repository error","error":"Task not found"} |

About

A Go API made for studies that manages tasks with user authentication

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages