- Notifications
You must be signed in to change notification settings - Fork15
pcraig3/hols
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a fun littleexpress app for Canada's statutory holidays. There's a frontend you can look at and an API you can use.
- The frontend is usinghtm 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.
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.
There's an OpenAPI spec atCanada-Holidays-API.v1.yaml
and aSwaggerHub page where you can test the endpoints.
npm
is a javascript package manager. It downloads project dependencies and runs node applications.
You'll need node versionv14
or higher to run the app. (If you have an M1 Mac, you'll needv15
or higher.)
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.
Install the dependencies and run it. "npm run dev" runs the JS contact + minify step, and reruns it if anything changes.
Pretty slick. 😎
# install dependenciesnpm 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 filenpm run build# run application in 'prod' mode (requires build step)npm start
The app should be running athttp://localhost:3000/.
On a Mac, pressControl
+C
to quit the running application.
# run unit testsnpmtest# run lintingnpm run lint
Since we are still using components as interface, this makes testing really easily. 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, usingcheerio
, 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 an image locallydocker build -t pcraig3/hols:tag --build-arg GITHUB_SHA_ARG=<tag>.# run the containerdocker run -it -p 3000:3000 pcraig3/hols:tag
The container should be running athttp://localhost:3000/.
On a Mac, pressControl
+C
to quit the running docker container.
Themain.yaml
file contains instructions to deploy the service toCloud 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}
About
hols for cans 📆