REST API for retrieving information author and books (retrieved from goodreads).
Use the script provided in src/bin/csv_to_data.ts
to import author csv from
data into the database, with the following format:
$ yarn run import <csv_file>
or
$ npx ts-node src/bin/csv_to_data.ts <csv_file>
GET /authors
- retrieve paginated list of information about authorsPOST /books
- create a book recordGET /books
- retrieve book recordsPUT /books/:id
- update existing record of a book provided withid
DELETE /books/:id
- delete a book record provided withid
Returns a paginated list of information about authors.
page
- number of page you want to retrieve (default: 1)limit
- number of items in a single page (default: 10)
[
{
"id": <id>,
"name": <author_name>,
}
...
]
Create a record containing the information of book.
Send post request ot the endpoint with the following request body
{
"name": "<name_of_the_book>",
"edition": "<edition_number_of_book>",
"publication_year": "<year_of_publication_of_book>",
"authors": "<array_of_author_id_from_author_endpoint>"
}
Retrieve a records about book information.
name
- name the book (optional)publication_year
- year of publication of the book (optional)edition
- edition of the book (optional)author
- name of the author (optional)
[
{
"id": "<id>",
"name": "<name_of_the_book>",
"edition": "<edition_of_book>",
"authors": "<array_of_author_of_book>"
}
...
]
Update existing records of a book. Identified using id
.
{
"name": "<name_of_the_book_if_wanted_to_change>",
"edition": "<edition_of_the_book_if_wanted_to_change>",
"publication_year": "<publication_year_of_the_book_if_wanted_to_change>",
"authors": "<array_of_author_ids_if_wanted_to_change>"
}
Delete a record of a book. Identified using id
.
Create a .env file with the following information:
POSTGRES_USER=<postrgres_username> POSTGRES_PASSWORD=<postrgres_password> POSTGRES_DB=<postgres_db_name>
- Docker
- docker-compose
Run the docker-compose to start the API server.
$ docker-compose up
- postgres
- node version > 12
- yarn
Install the node dependencies
$ yarn
Ensure that you have postrgres installed and it’s running on your system then start the server.
$ yarn start
Navigate to localhost:8080
and access the endpoints
This project uses a MIT License, which can be viewed here here.