https://github.com/samuelorlato/task-manager-api
A Go API made for studies that manages tasks with user authentication
https://github.com/samuelorlato/task-manager-api
api clean-architecture go golang hexagonal-architecture jwt todo-list
Last synced: 6 months ago
JSON representation
A Go API made for studies that manages tasks with user authentication
- Host: GitHub
- URL: https://github.com/samuelorlato/task-manager-api
- Owner: samuelorlato
- Created: 2023-12-12T22:24:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-17T23:33:37.000Z (over 2 years ago)
- Last Synced: 2024-06-19T19:33:30.365Z (about 2 years ago)
- Topics: api, clean-architecture, go, golang, hexagonal-architecture, jwt, todo-list
- Language: Go
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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"}` |