API for registering IMDb scores 🚀
ioasys_IMDb
|_ public
|_ coverage
|_ Postman
|_ src
|_ modules
|_ User
|_ __tests__
|_> User.spec.ts
|_ controllers
|_> UserController.ts
|_ dtos
|_> ICreateUserDTO.ts
|_ models
|_> User.ts
|_ repositories
|_> IUserRepository.ts
|_ Movie
|_ __tests__
|_ controllers
|_ dtos
|_ models
|_ repositories
|_ shared
|_ database
|_> app.ts
|_> bootstrap.ts
|_> routes.ts
|_> server.ts
_____________ ____________________ _______________
| Users | | Movies | | scores |
|_____________| |-------------------| |_______________|
| (1) id | | (2) id | | id |
| name | | title | | (1) id_user |
| password | | director | | (2) id_movie |
| nickname | | genre | | score |
| admin | | actors | | created_at |
| disabled | | year | | updated_at |
| created_at | | created_at | |_______________|
| updated_at | | updated_at |
|_____________| |___________________|
[ ] APP_SECRET (Using some MD5 generation service, create a key that only you know.)
[ ] DB_HOST (Your database host)
[ ] DB_PORT (Your database port, for PostgreSQL it is usually used at 5432)
[ ] DB_HOST_JEST (Your test database host)
Number | Type | Route | Definition |
---|---|---|---|
1 | Post | /login | Login |
2 | Post | /user | Create an user |
3 | Put | /user/id | Update an user |
4 | Delete | /user/:id | Disabled user |
5 | Post | /movie | Register new movie |
6 | Get | /movie | List all movies |
7 | Put | /movie/:id | Update an movie using id |
8 | Get | /movie/:id | Detail an movie using id |
9 | Post | /movie/:id/vote | score a movie using user id |
{
"email":"admin@gmail.com",
"password": "123"
}
{
"user": {
"name": "Lenilson Madureira",
"email": "admin@gmail.com"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2MDg1MDM1NTgsImV4cCI6MTYwODU4OTk1OCwic3ViIjoiMSJ9.bEu0P1Xqtcz9U4aonou-3Ejyr_DvX1l1Y5CdFO9plKw"
}
{
"name": "USER",
"nickname": "USER",
"email":"user1@user.com",
"password": "123",
"admin": false
}
{
"message": "User successfully registered",
"infos": {
"id": 2,
"name": "USER",
"nickname": "USER",
"email":"user1@user.com"
}
}
{
"name": "USER_UPDATED"
}
{
"User": {
"id": 2,
"name": "USER_UPDATED",
"nickname": "USER",
"email":"user1@user.com"
}
}
{
"success": "disabled"
}
{
"tt": "1414",
"title": "Gladiator",
"director":"Ridley Scott",
"genre": "Action | Adventure | Drama",
"actors": "Russell Crowe, Joaquin Phoenix, Connie Nielsen"
}
{
"message": "Movie successfully registered ✅",
"infos": {
"id": 4,
"tt": "1414",
"title": "Gladiator",
"year": null,
"director": "Ridley Scott",
"genre": "Action | Adventure | Drama",
"actors": "Russell Crowe, Joaquin Phoenix, Connie Nielsen"
}
}
[
{
"id": 1,
"tt": "4154796",
"title": "Avengers: Endgame (Vingadores: Ultimato)",
"year": "2019",
"director": "Anthony Russo, Joe Russo",
"genre": "Action, Adventure, Drama",
"actors": "Robert Downey Jr., Chris Evans, Mark Ruffalo",
"scores": [
{
"id": 1,
"user_id": 1,
"movie_id": 1,
"score": 4,
"createdAt": "2020-12-19T12:15:54.654Z",
"updatedAt": "2020-12-19T12:15:54.654Z"
},
{
"id": 2,
"user_id": 4,
"movie_id": 1,
"score": 2,
"createdAt": "2020-12-19T12:30:45.202Z",
"updatedAt": "2020-12-19T12:30:45.202Z"
},
{
"id": 3,
"user_id": 4,
"movie_id": 1,
"score": 2,
"createdAt": "2020-12-20T15:35:48.667Z",
"updatedAt": "2020-12-20T15:35:48.667Z"
}
]
},
{
"id": 2,
"tt": "0120815",
"title": "Saving Private Ryan",
"year": null,
"director": " Steven Spielberg",
"genre": "Drama | War",
"actors": " Tom Hanks, Matt Damon, Tom Sizemore",
"scores": []
},
{
"id": 4,
"tt": "55",
"title": "Avengers: Endgame (Vingadores: Ultimato)",
"year": "2019",
"director": "Anthony Russo, Joe Russo",
"genre": "Action, Adventure, Drama",
"actors": "Robert Downey Jr., Chris Evans, Mark Ruffalo",
"scores": []
},
{
"id": 3,
"tt": "0172495",
"title": "Gladiator",
"year": null,
"director": "Ridley Scott",
"genre": "Action | Adventure | Drama",
"actors": "Russell Crowe, Joaquin Phoenix, Connie Nielsen",
"scores": []
}
]
{
"tt": "1414",
"title": "Gladiator",
"director":"Ridley Scott",
"genre": "Action | Adventure | Drama",
"actors": "Russell Crowe, Joaquin Phoenix, Connie Nielsen"
}
{
"Movie": {
"id": "4",
"tt": "1414",
"title": "Gladiator",
"director":"Ridley Scott",
"genre": "Action | Adventure | Drama",
"actors": "Russell Crowe, Joaquin Phoenix, Connie Nielsen"
}
}
{{
"id": 4,
"tt": "1414",
"title": "Gladiator",
"director":"Ridley Scott",
"genre": "Action | Adventure | Drama",
"actors": "Russell Crowe, Joaquin Phoenix, Connie Nielsen"
"genre": "Action | Adventure | Drama",
"total_votes": 3,
"average_votes": 2.6666666666666665
}
{
"score": 2
}
{
"success": "vote successfully registered"
}