Skip to content
pcraig3Public

About

hols for cans 📆

Resources

Stars

122 stars

Watchers

2 watching

Forks

Repository files navigation

Canada Holidays

This is a fun little express app for Canada's statutory holidays. There's a website you can both look at and regarde, an API you can use, and calendars you can (should!) subscribe to.

  • The frontend is using htm server-rendered components. Very amusing.
  • The backend API is pretty bare-metal: it's using an initial SQLite migration file stored in memory and then it does "db reads" and spits out JSON.
  • Translations are managed with Rosetta, a tiny internationalization library.

Using the API

Please get in touch if you are using the API and you need something, because I can probably make it work better if I have enough real-life use-cases.

Read the API docs.

There's an OpenAPI spec at Canada-Holidays-API.v1.yaml and a SwaggerHub page where you can test the endpoints.

Adding holidays to your calendar

You can download or subscribe to holiday calendars in .ics format for Canada, the federal government, or individual provinces and territories.

Calendars are available in both English and French and can be used with Google Calendar, Apple Calendar, Outlook, and other applications that support the iCalendar format.

Calendars without an explicit year include holidays for the current and following year.

Internationalization (i18n)

The website supports English (en) and Canadian French (fr). English is the default language.

Localized routes

Every regular page is accessible in three ways:

English (default) English (explicit) French
/ /en/ /fr/
/federal /en/federal /fr/federal
/provinces/QC /en/provinces/QC /fr/provinces/QC
/about /en/about /fr/a-propos

English URLs without the /en prefix are canonical. French URLs always have a /fr prefix, and informational pages have translated URL paths.

API

The JSON API is language-independent and returns both English and French holiday and province names. Its endpoints do not use language prefixes.

Getting started

npm is a javascript package manager. It downloads project dependencies and runs node applications.

You'll need node version v24 or higher to run the app.

A docker container allows a developer to package up an application and all of its parts. This means we can build an app in any language, in any stack, and then run it anywhere — whether locally or on a server.

Build and run with npm

Install the dependencies and run it. "npm run dev" runs the JS concat + minify step, and reruns it if anything changes.

Pretty slick. 😎

# install dependencies
npm install

# run application in 'dev' mode
# (ie, the server restarts when you save a file)
npm run dev

# manually run build to create /js/min/bundle.min.js file
npm run build

# run application in 'prod' mode (requires build step)
npm start

The app should be running at http://localhost:3000/.

On a Mac, press Control + C to quit the running application.

Run tests with npm

# run unit tests
npm test

# run linting
npm run lint

Unit tests

Since we are still using components as interface, this makes testing really easy. On the server, we render out our components as strings that we send to the browser, but when we run tests, we want to do a bit more than that. Looking for values in big strings is pretty ugly.

Instead, using cheerio, we can load in a string like "<main><p>hello</p></main>" and then traverse it using jQuery selector syntax. So we can write assertions against stuff like $('main > p').text(), which is far better than string testing.

Build and run as a Docker container

# build an image locally
docker build -t pcraig3/hols:tag --build-arg GITHUB_SHA_ARG=<tag> .

# run the container
docker run -it -p 3000:3000 pcraig3/hols:tag

The container should be running at http://localhost:3000/.

On a Mac, press Control + C to quit the running docker container.

Push to Cloud Run

The main.yml file contains instructions to deploy the service to Cloud Run, or you can use the CLI command below to do it manually.

gcloud builds submit --tag gcr.io/{PROJECT}/{SERVICE}:{TAG} --build-arg GITHUB_SHA_ARG={TAG}

Citations

Region # Readable source (EN) Readable source (FR) Legislation
Federal 12 Statutory holiday pay Jours fériés payés —
AB 9 General holidays in Alberta — Employment Standards Code
BC 10 Statutory holidays in British Columbia — Entitlement to Statutory Holiday - Act Part 5, Section 44
MB 9 What are the general holidays in Manitoba? Quels sont les jours fériés au Manitoba? The Employment Standards Code
NB 8 What are the 11 prescribed days of rest? Quels sont les 11 jours prescrits de repos? Employment Standards Act
NL 12 2026 Paid Holidays — Labour Standards Act
NS 6 Paid holidays in Nova Scotia Jours fériés payés en Nouvelle-Écosse Labour Standards Code
NT 10 Statutory Holidays and Holiday Pay Jours fériés et rémunération des jours fériés Employment Standards Act
NU 10 General Holidays Jours fériés Labour Standards Act
ON 9 Public holidays Jours fériés Employment Standards Act
PE 8 Paid Holidays — Employment Standards Act
QC 8 Statutory holidays in Quebec Jours fériés au Québec Loi sur les normes du travail
SK 10 List of Saskatchewan Public Holidays Liste des jours fériés en Saskatchewan The Saskatchewan Employment Act
YT 10 Find a Yukon statutory holiday Jours fériés au Yukon Employment Standards Act

About

hols for cans 📆

Resources

Stars

122 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages