Welcome to Buoy's Node tech challenge!
This repository contains a partially implemented accommodations booking REST API, designed as a work-in-progress prototype for a real-world application.
You must use the provided code sample and its dependencies to solve the problems explained below.
The solution must be a cloud git repository, hosted on any cloud git tool of your choice.
- Its first commit must:
- Have the message "First commit"
- Have the exact code sample as it was provided, no changes whatsoever
- From this point on, work on the problems exposed below as you like
NOTE: In case you want to create a private git repository, please grant the user matthew@buoydevelopment.com full access to the repo. If you do so, please make it clear once you reply with your answer.
There's an Accommodations entity already in place, however the business model only includes Hotels and Apartments.
- Add this 2 new entities to the project.
- Provide endpoints for their management.
Currently, every Accommodation can contain several overlapping Bookings with the same startDate
and endDate
. This makes sense for Hotels, which can have different Rooms booked simultaneously, but it wouldn't work for Apartments.
- Apartments should not allow overlapping bookings during the same period (
startDate
andendDate
). - Hotels should allow overlapping bookings during the same period, as these would correspond to bookings for different rooms within the hotel.
The frontend needs to, given an accommodation's id
and a date
, retrieve the next available date for that accommodation.
- How would you solve this problem?
- What data or API would you provide to the frontend?
The main libraries are:
To set up the project using Docker Compose, follow these steps:
- Ensure you have Docker and Docker Compose installed on your machine.
- Build and start the Docker containers:
docker-compose up --build
- The application should now be running and accessible at
http://localhost:8006
.
http://localhost:8006/documentation
New migrations are applied every time the server is started.
Migrations will be needed when an existing entity changes any of it's Properties, is deleted, or a new one is added.
- Stop every running container:
docker compose down
- In one terminal, run the postgres container
docker compose up postgres
- In another terminal, run the following command:
docker-compose run --rm app npm run generate-migration
- If there are changes in the schema, a new migration will be created under
src/migrations
- Stop every running container:
docker compose down
- In one terminal, run the postgres container
docker compose up postgres
- In another terminal, run the following command:
docker-compose run --rm app npm run migration:up
- Stop every running container:
docker compose down
- In one terminal, run the postgres container
docker compose up postgres
- In another terminal, run the following command:
docker-compose run --rm app npm run migration:down