@gov-cy/govcy-express-services 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/package.json +1 -1
- package/src/middleware/govcyRoutePageHandler.mjs +12 -0
package/README.md
CHANGED
|
@@ -140,7 +140,13 @@ Here are some details explaining the JSON structure:
|
|
|
140
140
|
- `submission_data_version` : The submission data version,
|
|
141
141
|
- `renderer_version` : The govcy-frontend-renderer version,
|
|
142
142
|
- `design_systems_version` : The govcy-design-system version,
|
|
143
|
-
- `homeRedirectPage`:
|
|
143
|
+
- `homeRedirectPage`: An object mapping language codes to URLs. When a user visits the root route (e.g., `https://whatever-your-service-is.service.gov.cy/`), the system redirects to the URL for the user's language. If the user's language is not found, it falls back to `"el"` or the first available URL. If not provided, a list of available sites is shown. Example:
|
|
144
|
+
```json
|
|
145
|
+
"homeRedirectPage": {
|
|
146
|
+
"el": "https://www.gov.cy/service/aitisi-gia-taftotita/",
|
|
147
|
+
"en": "https://www.gov.cy/en/service/issue-an-id-card/"
|
|
148
|
+
}
|
|
149
|
+
```
|
|
144
150
|
- `matomo `: The Matomo web analytics configuration details.
|
|
145
151
|
- `eligibilityAPIEndpoints` : An array of API endpoints, to be used for service eligibility. See more on the [Eligibility API Endoints](#%EF%B8%8F-site-eligibility-checks) section below.
|
|
146
152
|
- `submissionAPIEndpoint`: The submission API endpoint, to be used for submitting the form. See more on the [Submission API Endoint](#-site-submissions) section below.
|
|
@@ -298,6 +304,9 @@ When designing form pages, refer to the Unified Design System's [question pages
|
|
|
298
304
|
**Error pages**
|
|
299
305
|
Pages that can be used to display messages when eligibility or submission fail are simply static content pages. That is pages that do not include a `form` element.
|
|
300
306
|
|
|
307
|
+
**Start page**
|
|
308
|
+
The [start page](https://gov-cy.github.io/govcy-design-system-docs/patterns/service_structure/#start-page) should be created in the gov.cy portal and should be defined in the `site.homeRedirectPage` property in the site config JSON file. All pages within a service are private by default and can only be accessed by authenticated users, so the start page cannot be created in the JSON file.
|
|
309
|
+
|
|
301
310
|
**Notes**:
|
|
302
311
|
- Check out the [govcy-frontend-renderer's design elements](https://github.com/gov-cy/govcy-frontend-renderer/blob/main/DESIGN_ELEMENTS.md) for more details on the supported elements and their parameters.
|
|
303
312
|
- Check out the [input validations section](#-input-validations) for more details on how to add validations to the JSON file.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gov-cy/govcy-express-services",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "An Express-based system that dynamically renders services using @gov-cy/govcy-frontend-renderer and posts data to a submission API.",
|
|
5
5
|
"author": "DMRID - DSF Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,6 +14,18 @@ export function govcyRoutePageHandler(req, res, next) {
|
|
|
14
14
|
const siteId = req.cookies.cs;
|
|
15
15
|
const serviceData = getServiceConfigData(siteId, req.globalLang);
|
|
16
16
|
if (serviceData.site && serviceData.site.homeRedirectPage) {
|
|
17
|
+
const homeRedirectPage = serviceData.site.homeRedirectPage;
|
|
18
|
+
const lang = req.globalLang || 'el'; // fallback to 'en' if not set
|
|
19
|
+
|
|
20
|
+
let redirectUrl = null;
|
|
21
|
+
|
|
22
|
+
if (homeRedirectPage && typeof homeRedirectPage === 'object') {
|
|
23
|
+
redirectUrl = homeRedirectPage[lang] || homeRedirectPage['el'] || Object.values(homeRedirectPage)[0];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (redirectUrl) {
|
|
27
|
+
return res.redirect(redirectUrl);
|
|
28
|
+
}
|
|
17
29
|
// redirect to the homeRedirectPage cookie
|
|
18
30
|
return res.redirect(serviceData.site.homeRedirectPage);
|
|
19
31
|
}
|