@gov-cy/govcy-express-services 0.1.4 → 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 CHANGED
@@ -14,6 +14,8 @@
14
14
  ## 📝 Description
15
15
  This project is an Express-based project that dynamically renders online service forms using `@gov-cy/govcy-frontend-renderer`. It is designed for developers building government services in Cyprus, enabling them to manage user authentication, form submissions, and OpenID authentication workflows in a timely manner.
16
16
 
17
+ The project is designed to support the [Linear structure](https://gov-cy.github.io/govcy-design-system-docs/patterns/service_structure/#variant-1---linear-structure) as described in the [Unified Design System](https://gov-cy.github.io/govcy-design-system-docs/).
18
+
17
19
  ![govcy-express-services](express-services.png)
18
20
 
19
21
  ## Table of contents
@@ -22,6 +24,7 @@ This project is an Express-based project that dynamically renders online service
22
24
  - [✨ Features](#-features)
23
25
  - [📋 Prerequisites](#-prerequisites)
24
26
  - [🚀 Quick start](#-quick-start)
27
+ - [✅ Best Practices](#-best-practices)
25
28
  - [📦 Full installation guide](#-full-installation-guide)
26
29
  - [🛠️ Usage](#%EF%B8%8F-usage)
27
30
  - [🧩 Dynamic services rendering](#-dynamic-services-rendering)
@@ -97,6 +100,15 @@ For more details on configuration, environment variables, and advanced features,
97
100
  ## 📦 Full installation guide
98
101
  The project acts as an npm package and you need to install it as a dependency in your npm project. Check out the [install notes](INSTALL-NOTES.md) a detailed installation guide.
99
102
 
103
+ ## ✅ Best Practices
104
+
105
+ Before starting your service, please review the [Best Practices guide](BEST-PRACTICES.md) for guidance on:
106
+
107
+ - Repository structure
108
+ - Environment separation (`dev` / `staging` / `prod`)
109
+ - Secure CY Login client registration
110
+ - Mandatory footer pages (privacy, cookies, accessibility)
111
+
100
112
  ## 🛠️ Usage
101
113
  ### Starting the Server
102
114
  Add in your `package.json`:
@@ -128,7 +140,13 @@ Here are some details explaining the JSON structure:
128
140
  - `submission_data_version` : The submission data version,
129
141
  - `renderer_version` : The govcy-frontend-renderer version,
130
142
  - `design_systems_version` : The govcy-design-system version,
131
- - `homeRedirectPage`: The page to redirect when user visits the route page. Usually this will redirect to gov.cy page. If not provided will show a list of available sites.
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
+ ```
132
150
  - `matomo `: The Matomo web analytics configuration details.
133
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.
134
152
  - `submissionAPIEndpoint`: The submission API endpoint, to be used for submitting the form. See more on the [Submission API Endoint](#-site-submissions) section below.
@@ -281,6 +299,14 @@ Lets break down the JSON config for this page:
281
299
  - Not perform the eligibility checks
282
300
  - Display the static content
283
301
 
302
+ When designing form pages, refer to the Unified Design System's [question pages pattern](https://gov-cy.github.io/govcy-design-system-docs/patterns/question_pages/).
303
+
304
+ **Error pages**
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.
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
+
284
310
  **Notes**:
285
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.
286
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.4",
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
  }