@gov-cy/govcy-express-services 0.1.3 β†’ 0.1.5

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.
Files changed (2) hide show
  1. package/README.md +67 -2
  2. package/package.json +1 -1
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`:
@@ -141,7 +153,7 @@ Here are some details explaining the JSON structure:
141
153
  A typical service flow that includes pages `index`, `question-1`, `question-2` under the `pages` array in the JSON file looks like this:
142
154
 
143
155
  ```mermaid
144
- flowchart TD
156
+ flowchart LR
145
157
  govcy-page --> isAuth{Is User Authenticated?}
146
158
  isAuth -- Yes<br><br> Eligibility Check --> index([:siteId/index])
147
159
  isAuth -- No --> cyLogin[cyLogin]
@@ -281,6 +293,11 @@ Lets break down the JSON config for this page:
281
293
  - Not perform the eligibility checks
282
294
  - Display the static content
283
295
 
296
+ 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/).
297
+
298
+ **Error pages**
299
+ 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
+
284
301
  **Notes**:
285
302
  - 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
303
  - Check out the [input validations section](#-input-validations) for more details on how to add validations to the JSON file.
@@ -380,6 +397,32 @@ With the above config, when a user visits a page under the specific site, `/:sit
380
397
 
381
398
  The response is cached to the session storage for the specified number of minutes. If the `cashingTimeoutMinutes` is set to `0`, the API endpoint will be called every time.
382
399
 
400
+ Here's a flowchart showing how the eligibility checks work:
401
+
402
+ ```mermaid
403
+ flowchart LR
404
+ A[🧭 User visits /:siteId/* page] --> B{{❓ Are eligibilityAPIEndpoints configured?}}
405
+ B -- No --> H[βœ… Access granted<br>Show page]
406
+ B -- Yes --> D[πŸ” Loop through API endpoints]
407
+
408
+ D --> D1{{❓ Is cached response still valid?}}
409
+ D1 -- Yes --> D2[πŸ—ƒοΈ Use cached result]
410
+ D1 -- No --> E[πŸ”„ Send request with:<br>- Method GET or POST<br>- Auth header<br>- Params or body]
411
+
412
+ D2 --> F{{❓ Did cached result<br>have Succeeded: true?}}
413
+ E --> F
414
+
415
+ F -- Yes --> G{{❓ More endpoints to check?}}
416
+ G -- Yes --> D
417
+ G -- No --> H
418
+
419
+ F -- No --> I[πŸ“„ Check ErrorCode<br>in config]
420
+ I --> J{{❓ Is ErrorCode in config?}}
421
+ J -- Yes --> K[❌ Redirect to configured error page]
422
+ J -- No --> L[❌ Show generic error page]
423
+
424
+ ```
425
+
383
426
  #### Eligibility API request and response
384
427
 
385
428
  For each eligibility API endpoint, the project sends a request to the API endpoint. The project uses the [CY Connect - OAuth 2.0 (CY Login)](https://dev.azure.com/cyprus-gov-cds/Documentation/_wiki/wikis/Documentation/122/CY-Connect-OAuth-2.0-(CY-Login)) authentication policy, so the user's `<access_token>` is sent in the `Authorization` header.
@@ -508,6 +551,27 @@ TEST_SUBMISSION_API_SERVIVE_ID=123
508
551
 
509
552
  With the above config, when a user submits the `review` page, the service sends a request to the configured submission API endpoint.
510
553
 
554
+ Here's a flowchart showing how the submission work:
555
+
556
+ ```mermaid
557
+
558
+ flowchart LR
559
+ A[πŸ“€ User submits review page] --> B[πŸ”„ Send POST request]
560
+
561
+ B --> C{{❓ Did response have Succeeded: true?}}
562
+
563
+ C -- Yes --> D[βœ… Show success confirmation with reference code]
564
+
565
+ C -- No --> E[πŸ“„ Check ErrorCode in config]
566
+ E --> F{{❓ Is ErrorCode in config?}}
567
+ F -- Yes --> G[❌ Redirect to configured error page]
568
+ F -- No --> H[❌ Show generic error page]
569
+
570
+ B --> I{{❓ Did request fail or return invalid response?}}
571
+ I -- Yes --> H
572
+
573
+ ```
574
+
511
575
  #### Submission API Request and Response
512
576
 
513
577
  **Submission Request:**
@@ -602,7 +666,7 @@ The data is collected from the form elements and the data layer and are sent via
602
666
  ##### Submission Data Sample
603
667
 
604
668
  <details>
605
- <summary>Here's a sample submission data JSON (as an object, before stringification)</summary>
669
+ <summary>Click here for a sample submission data JSON</summary>
606
670
 
607
671
  > ℹ️ **Note:**
608
672
  >
@@ -1120,6 +1184,7 @@ Absolutely! Here’s a **ready-to-paste Troubleshooting / FAQ section** you can
1120
1184
 
1121
1185
  ## πŸ”’ Security note
1122
1186
  - Always set a strong, random `SESSION_SECRET` in your `.env` file. Never commit secrets or credentials to version control.
1187
+ - Add `.gitignore` & `.npmignore`: Ensure no real `.env`, `server.key`, or other sensitive files are published.
1123
1188
  - In production, ensure cookies are set with `secure`, `httpOnly`, and `sameSite` attributes to protect against common web vulnerabilities.
1124
1189
  - Make sure your server is running behind HTTPS in production.
1125
1190
  - Regularly rotate secrets and credentials, and restrict access to your `.env` and configuration files.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gov-cy/govcy-express-services",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
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",