/holidays_api

NestJS API server that caches and serves holidays data from enrico service

Primary LanguageTypeScriptMIT LicenseMIT

Holidays API Callendar

The on demand caching country holiday and workdays API server

Description

Main task is to serve 4 endpoints to provide information about holidays, workdays and countries for which data is available. After the data is obtained from the third-party API it is saved to the PostgreSQL database.

The data is obtained from https://kayaposoft.com/enrico/.

Main scope was to create a small application, that would be error-prone, configurable, minimal and reliable.

Endpoints

The application serves 4 endpoints which return JSON as a response.

Endpoint Description Query Params
/countries Returns list of countries and their regions available.
Saves new, updates if data different different.
Has setting to check country list after request to check for changes.
No
/holidays Returns list of months with holiday days.
Saves new, updates existing, registers that all days are saved for requested year.
Has setting to hotload data from third-party API before making request to the database.
Yes
/status Returns day status (holiday, workday, freeday)
Saves new, updates existing, registers if all days are saved for one country (or region).
Can register that day was checked by all countries (and their regions)
Has setting to hotload data from third-party API before making request to the database.
Yes
/freedays Returns max number of freedays in a year
Saves new, updates existing, registers that all days are saved for requested year.
Has setting to hotload data from third-party API before making request to the database.
Yes
/api API documentation generated with Swagger on the endpoints above

Installation

$ npm install

Running the app

To connect application to the database it is required to change database settings in the config.yaml to match yours.

Application default port is 3001.

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

To enable /countries additional country check after response change try_source_after_success to true.

To enable hotload set hotload to true.