Loud Prefeitura de SΓ£o Paulo application is an API to handle with Opinions, comments and upvotes.
The project uses the most advanced software technologies, built with Typescript and SOLID Architecture
- Typescript 4.3.5
- MySQL 5.7
- TypeORM 0.2.34
- Docker 20.10.5
git clone https://github.com/GGotha/loud-prefeiturasp.git
yarn install
yarn typeorm migration:run
yarn db:seed
yarn start-dev
POST /user
route mode: public
{
"email": "[email protected]",
"name": "Test",
"password": "password",
"confirm_password": "password"
}
{
"success": true,
"user": {
"email": "[email protected]",
"name": "Test",
"created_at": "2021-07-05T20:06:47.633Z"
}
}
POST /user/session
route mode: public
{
"email": "[email protected]",
"password": "password"
}
{
"success": true,
"user": {
"id": 3,
"email": "[email protected]",
"name": "Test",
"created_at": "2021-07-05T20:06:48.000Z",
"updated_at": null,
"roles": {
"id": 2,
"name": "User",
"created_at": "2021-07-05T19:55:01.000Z",
"updated_at": null
}
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOnsiaWQiOjMsInJvbGUiOiJVc2VyIn0sImlhdCI6MTYyNTUxNTkwOCwiZXhwIjoxNjI1NjAyMzA4fQ.KMCraYELdIgxIz9GI8oqbXPEuq0_HxcL9Di8pPj2V1Y"
}
POST /opinion
route mode: user private
Authorization: Bearer ${sessionToken}
{
"content": "123"
}
{
"success": true,
"opinion": {
"id_user": 3,
"content": "123",
"created_at": "2021-07-05T20:34:10.515Z"
}
}
PUT /opinion/:opinionId
route mode: admin private
Authorization: Bearer ${sessionToken}
{
"content": "updated"
}
{
"success": true,
"opinion": {
"id_user": 1,
"content": "updated",
"created_at": "2021-07-05T20:36:40.888Z"
}
}
DELETE /opinion/:opinionId
route mode: admin private
Authorization: Bearer ${sessionToken}
{
"success": true,
"message": "Opinion has been deleted"
}
GET /opinion
route mode: public
{
"success": true,
"opinions": [
{
"id": 1,
"id_user": 1,
"content": "test opinion 1",
"upvotes": "5",
"created_at": "2021-07-05T19:55:01.000Z",
"updated_at": null
},
{
"id": 2,
"id_user": 2,
"content": "test opinion 2",
"upvotes": "1",
"created_at": "2021-07-05T19:55:01.000Z",
"updated_at": null
},
{
"id": 3,
"id_user": 2,
"content": "test opinion 3",
"upvotes": "1",
"created_at": "2021-07-05T19:55:01.000Z",
"updated_at": null
},
{
"id": 4,
"id_user": 1,
"content": "test opinion 4",
"upvotes": "1",
"created_at": "2021-07-05T19:55:01.000Z",
"updated_at": null
}
]
}
GET /opinion/:order
route mode: public
NOTE: order can be ASC or DESC
{
"success": true,
"opinions": [
{
"id": 4,
"id_user": 1,
"content": "test opinion 4",
"upvotes": "1",
"created_at": "2021-07-05T19:55:01.000Z",
"updated_at": null
},
{
"id": 2,
"id_user": 2,
"content": "test opinion 2",
"upvotes": "1",
"created_at": "2021-07-05T19:55:01.000Z",
"updated_at": null
},
{
"id": 3,
"id_user": 2,
"content": "test opinion 3",
"upvotes": "1",
"created_at": "2021-07-05T19:55:01.000Z",
"updated_at": null
},
{
"id": 1,
"id_user": 1,
"content": "test opinion 1",
"upvotes": "5",
"created_at": "2021-07-05T19:55:01.000Z",
"updated_at": null
}
]
}
POST /opinion-upvote/:opinionId
route mode: user private
Authorization: Bearer ${sessionToken}
{
"success": true,
"upvote": {
"id_user": 2,
"id_opinion": 1,
"upvote": true,
"created_at": "2021-07-05T20:16:45.786Z"
}
}
DELETE /opinion-upvote/:upvoteId
route mode: user private
Authorization: Bearer ${sessionToken}
{
"success": true,
"message": "Upvote has been deleted"
}
POST /opinion-comment
route mode: user private
Authorization: Bearer ${sessionToken}
{
"id_opinion": 2,
"comment": "test"
}
{
"success": true,
"opinionComment": {
"id_user": 3,
"id_opinion": 2,
"comment": "test",
"created_at": "2021-07-05T20:31:21.535Z"
}
}
PUT /opinion-comment/:opinionCommentId
route mode: user/admin private
Authorization: Bearer ${sessionToken}
{
"id_opinion": 2,
"comment": "updated"
}
{
"success": true,
"opinionComment": {
"id": 6,
"comment": "updated",
"created_at": "2021-07-05T23:31:21.000Z",
"updated_at": null
}
}
DELETE /opinion-comment/:opinionCommentId
route mode: user/admin private
Authorization: Bearer ${sessionToken}
{
"success": true,
"message": "Comment has been deleted"
}