@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.
- package/README.md +67 -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
|

|
|
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
|
|
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>
|
|
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
|
+
"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",
|