This project is a NestJS server-side application using PostgreSQL as the database. It is set up for local development with Docker and Prisma ORM.
Run the following command to start a local PostgreSQL instance:
docker compose up -dThis uses the configuration in docker-compose.yml and exposes the database on localhost:5432.
npm installnpx prisma migrate deploynpx prisma generatenpm run seedThis will add a test user (id=1) and a couple of calendar events for him.
- For development (with hot reload):
npm run start:dev
- For production:
npm run start:prod
The application will connect to the database started by Docker Compose.
/api
GET /api/users/{userId}/calendar/holidays
Description: Retrieve all holidays in the calendar for a specific user.
Path Parameters:
userId(integer, required): User ID
Responses:
200 OK: Array of holiday objects for the user404 Not Found: User not found500 Internal Server Error: Failed to fetch holidays
POST /api/users/{userId}/calendar/holidays
Description: Add public holidays for a given country and year to a user's calendar. Optionally, specify a list of holiday names to filter which holidays are added.
Path Parameters:
userId(integer, required): User ID
Request Body:
{
"countryCode": "US", // string, ISO 3166-1 alpha-2 country code, required
"year": 2025, // integer, required
"holidays": ["New Year's Day", "Independence Day"] // array of strings, optional
}Responses:
200 OK: List of added holidays404 Not Found: User not found or no holidays found500 Internal Server Error: Failed to fetch or save holidays
GET /api/countries
Description: Get a list of available countries for which public holiday data is available.
Responses:
200 OK: Array of countries with country codes and names500 Internal Server Error: Failed to fetch available countries
GET /api/countries/{countryCode}
Description: Get detailed information about a country, including borders, population, and flag.
Path Parameters:
countryCode(string, ISO 3166-1 alpha-2, required): Country code
Responses:
200 OK: Country info object500 Internal Server Error: Failed to fetch country info
Add holidays to user calendar:
curl -X POST \
http://localhost:3000/api/users/1/calendar/holidays \
-H 'Content-Type: application/json' \
-d '{
"countryCode": "US",
"year": 2025,
"holidays": ["New Year's Day"]
}'Get available countries:
curl http://localhost:3000/api/countriesGet country info:
curl http://localhost:3000/api/countries/US- The database data is persisted in the
postgres_data/directory. - Working .env file was added as per task requirements.
- Husky is configured with a pre-commit hook to automatically format all staged files before each commit.