@gov-cy/govcy-express-services 1.0.0-alpha.15 → 1.0.0-alpha.16

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
@@ -3,6 +3,7 @@
3
3
  ![License](https://img.shields.io/github/license/gov-cy/govcy-express-services)
4
4
  [![Unit test](https://github.com/gov-cy/govcy-express-services/actions/workflows/unit-test.yml/badge.svg)](https://github.com/gov-cy/govcy-express-services/actions/workflows/unit-test.yml)
5
5
  [![tag-and-publish-on-version-change](https://github.com/gov-cy/govcy-express-services/actions/workflows/tag-and-publish-on-version-change.yml/badge.svg)](https://github.com/gov-cy/govcy-express-services/actions/workflows/tag-and-publish-on-version-change.yml)
6
+ ![coverage](coverage-badges.svg)
6
7
 
7
8
  > ⚠️ **Warning:**
8
9
  > This package is **under active development** and is not a finished product. It is intended for testing, acceptance, integration, and browser testing purposes only.
@@ -29,15 +30,15 @@ The APIs used for submission, temporary save and file uploads are not part of th
29
30
  - [✅ Best Practices](#-best-practices)
30
31
  - [📦 Full installation guide](#-full-installation-guide)
31
32
  - [🛠️ Usage](#%EF%B8%8F-usage)
32
- - [🧩 Dynamic services rendering](#-dynamic-services-rendering)
33
+ - [🧩 Dynamic services](#-dynamic-services)
33
34
  - [🛡️ Site eligibility checks](#%EF%B8%8F-site-eligibility-checks)
34
35
  - [📤 Site submissions](#-site-submissions)
35
36
  - [✅ Input validations](#-input-validations)
36
- - [ Conditional logic](#-conditional-logic)
37
+ - [🔀 Conditional logic](#-conditional-logic)
37
38
  - [💾 Temporary save feature](#-temporary-save-feature)
38
39
  - [🗃️ Files uploads feature](#%EF%B8%8F-files-uploads-feature)
39
40
  - [🛣️ Routes](#%EF%B8%8F-routes)
40
- - [👨‍💻 Enviromental variables](#-enviromental-variables)
41
+ - [👨‍💻 Environment variables](#-environment-variables)
41
42
  - [🔒 Security note](#-security-note)
42
43
  - [❓ Troubleshooting / FAQ](#-troubleshooting--faq)
43
44
  - [🙏 Credits](#-credits)
@@ -141,7 +142,7 @@ The CY Login tokens are used to also connect with the various APIs through [cyCo
141
142
 
142
143
  The CY Login settings are configured in the `secrets/.env` file.
143
144
 
144
- ### 🧩 Dynamic Services Rendering
145
+ ### 🧩 Dynamic Services
145
146
  Services are rendered dynamically using JSON templates stored in the `/data` folder. All the service configuration, pages, routes, and logic is stored in the JSON files. The service will load `data/:siteId.json` to get the form data when a user visits `/:siteId/:pageUrl`. Checkout the [express-service-shema.json](express-service-shema.json) and the example JSON structure of the **[test.json](data/test.json)** file for more details.
146
147
 
147
148
  Here is an example JSON config:
@@ -1266,7 +1267,7 @@ The data is collected from the form elements and the data layer and are sent via
1266
1267
  "id_number": "654654",
1267
1268
  "arc_number": "",
1268
1269
  "aka": "232323",
1269
- "evidenceAttachments": // File attachments contains an object with `fileId` and `sha256`
1270
+ "evidenceAttachment": // File attachments contains an object with `fileId` and `sha256`
1270
1271
  {
1271
1272
  "fileId": "1234567891234567890",
1272
1273
  "sha256": "123456789012345678901234567890123456789012345678901234567890123456"
@@ -1744,7 +1745,7 @@ Example:
1744
1745
  ]
1745
1746
  ```
1746
1747
 
1747
- ### Conditional logic
1748
+ ### 🔀 Conditional logic
1748
1749
 
1749
1750
  The project supports conditional logic on pages. Conditional logic is evaluated using a custom `govcyExpressions.mjs` module, which executes expressions in a safe and scoped context using `new Function`. Only safe data access through the `dataLayer` is allowed. The system uses expressions and session data from the service's [data layer](NOTES.md#data-layer) to decide if a page will be shown or not.
1750
1751
 
@@ -2487,7 +2488,7 @@ The project uses express.js to serve the following routes:
2487
2488
  #### API routes:
2488
2489
  - **`/apis/:siteId/:pageUrl/upload`**: Uploads a file. Used from the client side JS.
2489
2490
 
2490
- ### 👨‍💻 Enviromental variables
2491
+ ### 👨‍💻 Environment variables
2491
2492
  The environment variables are defined in:
2492
2493
  - **Secret environment variables**: These are secret variables and MUSR NOT be saved in version control. The are saved locally in the `secrets/.env` file and they control the server configuration, authentication, integrations, and development behavior. These variables vary depending on the environment and are defined through the deployment prosses for `staging` and `production`.
2493
2494
  - **Non secret environment variables**: These are non secret enviromentat variables and can be saved in version control. These are stored in the root folder of the project:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gov-cy/govcy-express-services",
3
- "version": "1.0.0-alpha.15",
3
+ "version": "1.0.0-alpha.16",
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",
@@ -45,8 +45,9 @@
45
45
  "test:package": "mocha --recursive tests/package/**/*.test.mjs",
46
46
  "test:functional": "mocha --timeout 30000 --recursive tests/functional/**/*.test.mjs",
47
47
  "test:watch": "mocha --watch --timeout 60000 tests/**/*.test.mjs",
48
- "coverage": "c8 --reporter=html --reporter=text --reporter=lcov --reporter=cobertura npm test",
49
- "coverage:report": "c8 report"
48
+ "coverage": "c8 --reporter=html --reporter=text --reporter=lcov --reporter=json-summary npm test",
49
+ "coverage:report": "c8 report",
50
+ "coverage:badge": "coverage-badges --output ./coverage-badges.svg"
50
51
  },
51
52
  "dependencies": {
52
53
  "@gov-cy/dsf-email-templates": "^2.1.0",
@@ -65,6 +66,7 @@
65
66
  "c8": "^10.1.3",
66
67
  "chai": "^5.2.0",
67
68
  "chai-http": "^5.1.1",
69
+ "coverage-badges-cli": "^2.2.0",
68
70
  "mocha": "^11.1.0",
69
71
  "mochawesome": "^7.1.3",
70
72
  "nodemon": "^3.0.2",
@@ -2,7 +2,7 @@ import * as client from 'openid-client';
2
2
  import { getEnvVariable } from '../utils/govcyEnvVariables.mjs';
3
3
  import { logger } from "../utils/govcyLogger.mjs";
4
4
 
5
-
5
+ /* c8 ignore start */
6
6
  // OpenID Configuration
7
7
  const issuerUrl = getEnvVariable('CYLOGIN_ISSUER_URL');
8
8
  const clientId = getEnvVariable('CYLOGIN_CLIENT_ID');
@@ -131,3 +131,4 @@ export function getLogoutUrl(id_token_hint = '') {
131
131
 
132
132
  // Export config if needed elsewhere
133
133
  export { config };
134
+ /* c8 ignore end */
@@ -10,6 +10,7 @@ import { handleMiddlewareError } from "../utils/govcyUtils.mjs";
10
10
  import { errorResponse } from "../utils/govcyApiResponse.mjs";
11
11
  import { isApiRequest } from '../utils/govcyApiDetection.mjs';
12
12
 
13
+ /* c8 ignore start */
13
14
  /**
14
15
  * Middleware to check if the user is authenticated. If not, redirect to the login page.
15
16
  *
@@ -136,4 +137,5 @@ export function handleLogout() {
136
137
  res.redirect(logoutUrl);
137
138
  });
138
139
  };
139
- }
140
+ }
141
+ /* c8 ignore end */
@@ -6,6 +6,7 @@ import { logger } from "../utils/govcyLogger.mjs";
6
6
  * Middleware function to render PDFs using the GovCy Frontend Renderer.
7
7
  * This function takes the processed page data and template, and generates the final PDF response.
8
8
  */
9
+ /* c8 ignore start */
9
10
  export function govcyPDFRender() {
10
11
  return async (req, res) => {
11
12
  try {
@@ -29,4 +30,5 @@ export function govcyPDFRender() {
29
30
  res.status(500).send('Unable to generate PDF at this time.');
30
31
  }
31
32
  };
32
- }
33
+ }
34
+ /* c8 ignore end */
@@ -4,5 +4,5 @@
4
4
  export const ALLOWED_FORM_ELEMENTS = ["textInput", "textArea", "select", "radios", "checkboxes", "datePicker", "dateInput","fileInput","fileView"];
5
5
  export const ALLOWED_FILE_MIME_TYPES = ['application/pdf', 'image/jpeg', 'image/png'];
6
6
  export const ALLOWED_FILE_EXTENSIONS = ['pdf', 'jpg', 'jpeg', 'png'];
7
- export const ALLOWED_FILE_SIZE_MB = 5; // Maximum file size in MB
7
+ export const ALLOWED_FILE_SIZE_MB = 4; // Maximum file size in MB
8
8
  export const ALLOWED_MULTER_FILE_SIZE_MB = 10; // Maximum file size in MB