Challenge of building an API using nestjs Nest framework TypeScript and PostgreSql.
https://github.com/EduDevHe/challenge-nestJs-postgresql.git
# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prod
docker-compose up --build
http://localhost:3000/place/1
{
"id": 1,
"name": "rio",
"state": "bahia",
"city": "barreiras",
"createdAt": "2024-01-11T00:28:03.143Z",
"updatedAt": "2024-01-11T00:28:03.143Z"
}
http://localhost:3000/place/all
[
{
"id": 1,
"name": "rio",
"state": "bahia",
"city": "barreiras",
"createdAt": "2024-01-11T00:28:03.143Z",
"updatedAt": "2024-01-11T00:28:03.143Z"
},
{
"id": 2,
"name": "cais",
"state": "bahia",
"city": "barreiras",
"createdAt": "2024-01-11T00:28:19.339Z",
"updatedAt": "2024-01-11T00:28:19.339Z"
},
{
"id": 3,
"name": "centro",
"state": "bahia",
"city": "barreiras",
"createdAt": "2024-01-11T00:28:10.101Z",
"updatedAt": "2024-01-11T01:31:58.283Z"
}
]
http://localhost:3000/place?name=barreirinhas
http://localhost:3000/place?name=barreirinhas&state=bahia
[
{
"id": 5,
"name": "barreirinhas",
"state": "bahia",
"city": "barreiras",
"createdAt": "2024-01-11T00:28:03.143Z",
"updatedAt": "2024-01-11T00:28:03.143Z"
}
]
http://localhost:3000/place/create
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`,
},
{
"name":"centro",
"city":"barreiras",
"state":"bahia"
}
{
"message": "Place created successfully",
"place": {
"id": 8,
"name": "centro",
"state": "bahia",
"city": "barreiras",
"createdAt": "2024-01-11T03:10:31.861Z",
"updatedAt": "2024-01-11T03:10:31.861Z"
}
}
You need to be authenticated with a valid jwt token
http://localhost:3000/place/8
method: 'DELETE',
headers: {
'Authorization': `Bearer ${token}`,
},
{
"message": "Deleted place",
"place": {
"id": 8,
"name": "centro",
"state": "bahia",
"city": "barreiras",
"createdAt": "2024-01-11T03:10:31.861Z",
"updatedAt": "2024-01-11T03:10:31.861Z"
}
}
You need to be authenticated with a valid jwt token
http://localhost:3000/place/7
method: 'PATCH',
headers: {
'Authorization': `Bearer ${token}`,
},
{
"name":"centro"
}
{
"message": "Updated place",
"place": {
"id": 7,
"name": "centro",
"state": "bahia",
"city": "barreiras",
"createdAt": "2024-01-11T00:28:19.339Z",
"updatedAt": "2024-01-11T04:18:01.780Z"
}
}
http://localhost:3000/auth/register
{
"username":"test",
"email": "[email protected]",
"password": "12345"
}
{
"message": "User created successfully",
"username": "test",
"email": "[email protected]",
"createdAt": "2024-01-11T03:27:02.702Z"
}
http://localhost:3000/auth/login
{
"email": "[email protected]",
"password": "12345"
}
{
"message": "login successfully",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3QiLCJzdWIiOjUsImlhdCI6MTcwNDk0MzY1MSwiZXhwIjoxNzA0OTQ3MjUxfQ.Wa3lx6HUv6x5h90HBpb1DdF6ivHa8Ohybgr_ycekNHw",
"login": true
}