This project was created as an example of "How to Create a Nodejs API" for educational porposes.
To install all dependencies, you must run the following command:
$ pnpm install
Define the environament variables:
MONGO_CONNECTION_STRING=mongodb://localhost:27017/georwell
To run the application:
$ pnpm start
To start server into a docker container:
$ docker build -t thrsouza/georwell .
$ docker run --name georwell -p 3000:3000 -d thrsouza/georwell
Authors
- GET: /api/authors
// GET http://localhost:3000/api/authors
// RESPONSE (STATUS: 200)
[
{
name: String,
createAt: Date,
id: String
}
]
- GET: /api/authors/:id
// GET http://localhost:3000/api/authors/:id
// RESPONSE (STATUS: 200)
{
"name": String,
"createAt": Date,
"id": String
}
- POST: /api/authors/
// POST http://localhost:3000/api/authors
// REQUEST (BODY: JSON)
{
"name": String
}
// RESPONSE (STATUS: 201)
{
"name": String,
"createAt": Date,
"id": String
}
- PUT: /api/authors/:id
// PUT http://localhost:3000/api/authors/:id
// REQUEST (BODY: JSON)
{
"name": String
}
// RESPONSE (STATUS: 204)
- DELETE: /api/authors/:id
// DELETE http://localhost:3000/api/authors/:id
// RESPONSE (STATUS: 204)
Books
- GET: /api/books
// GET http://localhost:3000/api/books
// RESPONSE (STATUS: 200)
[
{
name: String,
year: Number,
author: {
name: String,
createAt: Date,
id: String
},
createAt: Date,
id: String
}
]
- GET: /api/books/:id
// GET http://localhost:3000/api/books/:id
// RESPONSE (STATUS: 200)
{
"name": String,
"year": Number,
"author": {
"name": String,
"createAt": Date,
"id": String
},
"createAt": Date,
"id": String
}
- POST: /api/books/
// POST http://localhost:3000/api/books/:id
// REQUEST (BODY: JSON)
{
"name": String,
"year": Number,
"author": String
}
// RESPONSE (STATUS: 201)
{
"name": String,
"year": Number,
"author": {
"name": String,
"createAt": Date,
"id": String
},
"createAt": Date,
"id": String
}
- PUT: /api/books/:id
// PUT http://localhost:3000/api/books/:id
// REQUEST (BODY: JSON)
{
"name": String,
"year": Number,
"author": String
}
// RESPONSE (STATUS: 204)
- DELETE: /api/books/:id
// DELETE http://localhost:3000/api/books/:id
// RESPONSE (STATUS: 204)