A shared codesets / resources router for Virtual Finland projects
If using docker compose, the following network must be created: vfd-network
.
Create the network with command:
docker network create vfd-network
Start up the service with docker compose:
docker compose up
Natively with nodejs:
npm install && npm run start
View the available codeset resources at http://localhost:3166
Codesets are defined in src/resources/internal, src/resources/library and src/resources/extrenal folders:
- interal: raw resource files that are served directly from the codeset services backend (S3-bucket / cloudfront)
- library: resources that are built to the codeset service as a library: nodejs module with default export
- external: resources that are resolved programmatically from external sources (e.g. github), cached and then served from the codeset services backend
- external resources are defined as Resource or ZipResource class which at minimum requires an
uri
andname
property. Theuri
is used to resolve the resource and thename
is used to identify the resource in the codeset service.
- external resources are defined as Resource or ZipResource class which at minimum requires an
The external resource parsers can be defined using the parsers
attribute of the inherited BaseResource constructor call. The parsers are defined as follows:
{
...,
parsers: {
rawInput?: (data: string) => unknown; // Raw input string -> data (e.g. JSON.parse)
input?: BaseSchema || (data: unknown) => unknown; // data intake -> parsed data schema
transform?: (data: unknown, params?: Record<string, string>) => Promise<unknown>; // Parsed data intake with query params obj -> transformed data
output?: BaseSchema || (data: unknown) => unknown; // Transformed data intake -> output data schema
rawOutput?: (data: unknown) => string; // Output data intake -> raw output string (e.g. JSON.stringify)
}
}
Where BaseSchema
is a valibot schema object.
Some of the codeset resources support filtering the data with query parameters. Supported filter parameters types are:
filters
- comma separated list of static filter namesquery
- comma separated text search querylocales
- comma separated list of locales
Example query:
GET /resources/Skills?query=foo&locales=fi
Example response:
[
{
"uri": "http://data.europa.eu/esco/skill/f6d294f4-db62-4fc5-a7b8-778e5071c112",
"prefLabel": { "fi": "moderoida keskustelufoorumia" }
}
]
- valibot - data schema parser library