@gov-cy/govcy-express-services 0.2.11 β 0.2.12
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
|
@@ -151,7 +151,6 @@ Here are some details explaining the JSON structure:
|
|
|
151
151
|
"en": "https://www.gov.cy/en/service/issue-an-id-card/"
|
|
152
152
|
}
|
|
153
153
|
```
|
|
154
|
-
- `matomo `: The Matomo web analytics configuration details.
|
|
155
154
|
- `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.
|
|
156
155
|
- `submissionAPIEndpoint`: The submission API endpoint, to be used for submitting the form. See more on the [Submission API Endoint](#-site-submissions) section below.
|
|
157
156
|
- `pages` array: An array of page objects, each representing a page in the site.
|
|
@@ -1431,10 +1430,15 @@ The project uses express.js to serve the following routes:
|
|
|
1431
1430
|
Absolutely! Hereβs a **ready-to-paste Troubleshooting / FAQ section** you can add near the end of your README, just before Credits or Developer notes.
|
|
1432
1431
|
|
|
1433
1432
|
### π¨βπ» Enviromental variables
|
|
1434
|
-
The environment variables
|
|
1433
|
+
The environment variables are defined in:
|
|
1434
|
+
- **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`.
|
|
1435
|
+
- **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:
|
|
1436
|
+
- `.env.development` for local development
|
|
1437
|
+
- `.env.staging` for staging
|
|
1438
|
+
- `.env.production` for production
|
|
1435
1439
|
|
|
1436
|
-
####
|
|
1437
|
-
The following environment variables are used to configure the server:
|
|
1440
|
+
#### Secret environment variables
|
|
1441
|
+
The following secret environment variables are used to configure the server:
|
|
1438
1442
|
|
|
1439
1443
|
```dotenv
|
|
1440
1444
|
# π Session
|
|
@@ -1454,12 +1458,9 @@ DEBUG=true
|
|
|
1454
1458
|
ALLOW_SELF_SIGNED_CERTIFICATES=false
|
|
1455
1459
|
# Allow self-signed SSL certs (e.g. for local development). Set to false in production.
|
|
1456
1460
|
|
|
1457
|
-
|
|
1458
|
-
|
|
1461
|
+
# -----------------------------------------------
|
|
1459
1462
|
#### CY Login environment variables
|
|
1460
|
-
The following environment variables are used to configure CY Login authentication:
|
|
1461
|
-
|
|
1462
|
-
```dotenv
|
|
1463
|
+
# The following environment variables are used to configure CY Login authentication:
|
|
1463
1464
|
CYLOGIN_ISSUER_URL=https://aztest.cyprus.gov.cy/cylogin/core/.well-known/openid-configuration
|
|
1464
1465
|
# The OIDC issuer URL for discovery.
|
|
1465
1466
|
|
|
@@ -1478,12 +1479,10 @@ CYLOGIN_CODE_CHALLENGE_METHOD=S256
|
|
|
1478
1479
|
|
|
1479
1480
|
CYLOGIN_POST_LOGOUR_REIDRECT_URI=https://localhost:44319/
|
|
1480
1481
|
# Where to redirect users after logout.
|
|
1481
|
-
```
|
|
1482
1482
|
|
|
1483
|
+
# -----------------------------------------------
|
|
1483
1484
|
#### DSF API Gateway environment variables
|
|
1484
|
-
The following environment variables are used to configure the DSF API Gateway. The DSF API Gateway is used to send notifications to the NotificationEngine API.
|
|
1485
|
-
|
|
1486
|
-
```dotenv
|
|
1485
|
+
# The following environment variables are used to configure the DSF API Gateway. The DSF API Gateway is used to send notifications to the NotificationEngine API.
|
|
1487
1486
|
DSF_API_GTW_CLIENT_ID=your-DSF-API-gateway-client-id
|
|
1488
1487
|
DSF_API_GTW_SECRET=your-DSF-API-gateway-secret
|
|
1489
1488
|
DSF_API_GTW_SERVICE_ID=your-DSF-API-gateway-service-id
|
|
@@ -1491,12 +1490,10 @@ DSF_API_GTW_SERVICE_ID=your-DSF-API-gateway-service-id
|
|
|
1491
1490
|
|
|
1492
1491
|
DSF_API_GTW_NOTIFICATION_API_URL=https://127.0.0.1/api/v1/NotificationEngine/simple-message
|
|
1493
1492
|
# URL for the NotificationEngine API.
|
|
1494
|
-
```
|
|
1495
1493
|
|
|
1494
|
+
#-----------------------------------------------
|
|
1496
1495
|
#### Service API environmental variables
|
|
1497
|
-
The following environment variables are used to configure the services (they are referenced in the JSON config file):
|
|
1498
|
-
|
|
1499
|
-
```dotenv
|
|
1496
|
+
# The following environment variables are used to configure the services (they are referenced in the JSON config file):
|
|
1500
1497
|
# Submission endpoint (test service)
|
|
1501
1498
|
TEST_SUBMISSION_API_URL=http://localhost:3002/submission
|
|
1502
1499
|
TEST_SUBMISSION_API_CLIENT_KEY=12345678901234567890123456789000
|
|
@@ -1507,6 +1504,14 @@ TEST_SUBMISSION_DSF_GTW_KEY=12345678901234567890123456789000
|
|
|
1507
1504
|
TEST_ELIGIBILITY_1_API_URL=http://localhost:3002/eligibility1
|
|
1508
1505
|
TEST_ELIGIBILITY_2_API_URL=http://localhost:3002/eligibility2
|
|
1509
1506
|
```
|
|
1507
|
+
#### Non secret environment variables
|
|
1508
|
+
The following non-secret environment variables are used to configure the server defined in `.env.development` for local development, `.env.staging` for staging, and `.env.production` for production.:
|
|
1509
|
+
|
|
1510
|
+
```dotenv
|
|
1511
|
+
#### Matomo web analytics environment variables
|
|
1512
|
+
MATOMO_SITE_ID=51
|
|
1513
|
+
MATOMO_URL=//wp.matomo.dits.dmrid.gov.cy
|
|
1514
|
+
```
|
|
1510
1515
|
|
|
1511
1516
|
## π Security note
|
|
1512
1517
|
- Always set a strong, random `SESSION_SECRET` in your `secrets/.env` file. Never commit secrets or credentials to version control.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gov-cy/govcy-express-services",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
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",
|
|
@@ -6,12 +6,19 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import * as dotenv from 'dotenv';
|
|
9
|
+
import fs from 'fs';
|
|
9
10
|
import { dirname, join } from 'path';
|
|
10
11
|
|
|
11
12
|
// Load environment variables from .env file
|
|
12
13
|
let envFilePath = join(process.cwd(),'secrets', '.env');
|
|
13
14
|
dotenv.config({ path: envFilePath });
|
|
14
15
|
|
|
16
|
+
// Load additional environment variables from .env.{{environment}}
|
|
17
|
+
let configPathEnv = join(process.cwd(),'.env.' + whatsIsMyEnvironment());
|
|
18
|
+
if (fs.existsSync(configPathEnv)) {
|
|
19
|
+
dotenv.config({ path: configPathEnv, override: false }); // don't override existing vars from secrets
|
|
20
|
+
}
|
|
21
|
+
//:todo, when loading the service, change `matomo.url` and `matomo.siteId` to the service's values
|
|
15
22
|
/**
|
|
16
23
|
* Check if the current environment is production
|
|
17
24
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
9
|
-
import { whatsIsMyEnvironment } from './govcyEnvVariables.mjs';
|
|
9
|
+
import { whatsIsMyEnvironment, getEnvVariable} from './govcyEnvVariables.mjs';
|
|
10
10
|
import { logger } from "./govcyLogger.mjs";
|
|
11
11
|
|
|
12
12
|
|
|
@@ -76,6 +76,11 @@ export function getServiceConfigData(siteId,lang) {
|
|
|
76
76
|
//Handle TESTING banner: check if staging and set isTesting
|
|
77
77
|
serviceCopy.site.isTesting = (whatsIsMyEnvironment() === "staging");
|
|
78
78
|
|
|
79
|
+
//Handle matomo: Set Matomo URL and siteId
|
|
80
|
+
serviceCopy.site.matomo = {
|
|
81
|
+
url: getEnvVariable('MATOMO_URL', 'https://wp.matomo.dits.dmrid.gov.cy/'),
|
|
82
|
+
siteId: getEnvVariable('MATOMO_SITE_ID', '50')
|
|
83
|
+
};
|
|
79
84
|
// Add manifest path
|
|
80
85
|
serviceCopy.site.manifest = `/${siteId}/manifest.json`;
|
|
81
86
|
|