@hmcts/opal-frontend-common-node 0.0.3 → 0.0.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 +109 -0
- package/interfaces/session-storage-config.d.ts +1 -1
- package/interfaces/session-storage-config.d.ts.map +1 -1
- package/interfaces/session-storage-config.js.map +1 -1
- package/package.json +2 -2
- package/session/session-storage/index.js +1 -1
- package/session/session-storage/index.js.map +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# OPAL Frontend Common Node Library
|
|
2
|
+
[](https://www.npmjs.com/package/@hmcts/opal-frontend-common-node)
|
|
3
|
+
[](https://github.com/hmcts/opal-frontend-common-node-lib/blob/main/LICENSE)
|
|
4
|
+
[](https://sonarcloud.io/summary/new_code?id=hmcts_opal-frontend-common-node-lib)
|
|
5
|
+
|
|
6
|
+
This is a shared Node.js library containing common middleware, configurations, and utilities used across OPAL backend services.
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Getting Started](#getting-started)
|
|
11
|
+
- [Scripts](#scripts)
|
|
12
|
+
- [Build Process](#build-process)
|
|
13
|
+
- [Linting and Formatting](#linting-and-formatting)
|
|
14
|
+
- [Exports](#exports)
|
|
15
|
+
- [Using This Library in a Node.js Application](#using-this-library-in-a-nodejs-application)
|
|
16
|
+
|
|
17
|
+
## Getting Started
|
|
18
|
+
|
|
19
|
+
### Prerequisites
|
|
20
|
+
|
|
21
|
+
Ensure you have the following installed:
|
|
22
|
+
|
|
23
|
+
- [Node.js](https://nodejs.org/) v18 or later
|
|
24
|
+
- [Yarn](https://classic.yarnpkg.com/) v1.22.22 or later
|
|
25
|
+
|
|
26
|
+
### Install Dependencies
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
yarn
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Scripts
|
|
33
|
+
|
|
34
|
+
The following commands are available in the `package.json`:
|
|
35
|
+
|
|
36
|
+
- `yarn build`
|
|
37
|
+
Cleans the `dist/` folder, compiles TypeScript, and copies relevant files to `dist/`.
|
|
38
|
+
|
|
39
|
+
- `yarn clean`
|
|
40
|
+
Removes the `dist/` directory.
|
|
41
|
+
|
|
42
|
+
- `yarn lint`
|
|
43
|
+
Runs ESLint across the `src/` directory and checks formatting using Prettier.
|
|
44
|
+
|
|
45
|
+
- `yarn prettier`
|
|
46
|
+
Checks if files are formatted correctly.
|
|
47
|
+
|
|
48
|
+
- `yarn prettier:fix`
|
|
49
|
+
Automatically formats the codebase.
|
|
50
|
+
|
|
51
|
+
## Build Process
|
|
52
|
+
|
|
53
|
+
Run the following to build the project:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
yarn build
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The compiled output will be available in the `dist/` folder. It includes `index.js`, type declarations, and any exported modules listed in the `exports` field.
|
|
60
|
+
|
|
61
|
+
## Linting and Formatting
|
|
62
|
+
|
|
63
|
+
To lint and check formatting:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
yarn lint
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
To fix formatting issues automatically:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
yarn prettier:fix
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Exports
|
|
76
|
+
|
|
77
|
+
This library exposes multiple entry points under the `exports` field of `package.json`. Example usage:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { CSRFToken } from '@hmcts/opal-frontend-common-node/csrf-token';
|
|
81
|
+
import { AppInsights } from '@hmcts/opal-frontend-common-node/app-insights';
|
|
82
|
+
import { Helmet } from '@hmcts/opal-frontend-common-node/helmet';
|
|
83
|
+
import { LaunchDarkly } from '@hmcts/opal-frontend-common-node/launch-darkly';
|
|
84
|
+
import {
|
|
85
|
+
ExpiryConfiguration,
|
|
86
|
+
RoutesConfiguration,
|
|
87
|
+
SessionStorageConfiguration,
|
|
88
|
+
TransferServerState,
|
|
89
|
+
} from '@hmcts/opal-frontend-common-node/interfaces';
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Refer to the `exports` block in `package.json` for the full list of available modules.
|
|
93
|
+
|
|
94
|
+
## Using This Library in a Node.js Application
|
|
95
|
+
|
|
96
|
+
Install the published package using:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
yarn add @hmcts/opal-frontend-common-node
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
If consuming from a local build:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
yarn remove @hmcts/opal-frontend-common-node
|
|
106
|
+
yarn add @hmcts/opal-frontend-common-node@file:../opal-frontend-common-node-lib/dist
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Ensure paths reflect your actual local setup when using the `file:` specifier.
|
|
@@ -6,7 +6,7 @@ declare class SessionStorageConfiguration {
|
|
|
6
6
|
secure: boolean;
|
|
7
7
|
domain: string;
|
|
8
8
|
redisEnabled: boolean;
|
|
9
|
-
redisConnectionString: string
|
|
9
|
+
redisConnectionString: string;
|
|
10
10
|
}
|
|
11
11
|
export default SessionStorageConfiguration;
|
|
12
12
|
//# sourceMappingURL=session-storage-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-storage-config.d.ts","sourceRoot":"","sources":["../../src/interfaces/session-storage-config.ts"],"names":[],"mappings":"AAAA,cAAM,2BAA2B;IAC/B,MAAM,EAAG,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,QAAQ,EAAG,OAAO,CAAC;IACnB,MAAM,EAAG,OAAO,CAAC;IACjB,MAAM,EAAG,MAAM,CAAC;IAChB,YAAY,EAAG,OAAO,CAAC;IACvB,qBAAqB,EAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"session-storage-config.d.ts","sourceRoot":"","sources":["../../src/interfaces/session-storage-config.ts"],"names":[],"mappings":"AAAA,cAAM,2BAA2B;IAC/B,MAAM,EAAG,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,QAAQ,EAAG,OAAO,CAAC;IACnB,MAAM,EAAG,OAAO,CAAC;IACjB,MAAM,EAAG,MAAM,CAAC;IAChB,YAAY,EAAG,OAAO,CAAC;IACvB,qBAAqB,EAAG,MAAM,CAAC;CAChC;AAED,eAAe,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-storage-config.js","sourceRoot":"","sources":["../../src/interfaces/session-storage-config.ts"],"names":[],"mappings":"AAAA,MAAM,2BAA2B;IAC/B,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,QAAQ,CAAW;IACnB,MAAM,CAAW;IACjB,MAAM,CAAU;IAChB,YAAY,CAAW;IACvB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"session-storage-config.js","sourceRoot":"","sources":["../../src/interfaces/session-storage-config.ts"],"names":[],"mappings":"AAAA,MAAM,2BAA2B;IAC/B,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,QAAQ,CAAW;IACnB,MAAM,CAAW;IACjB,MAAM,CAAU;IAChB,YAAY,CAAW;IACvB,qBAAqB,CAAU;CAChC;AAED,eAAe,2BAA2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmcts/opal-frontend-common-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"description": "Common nodejs library components for opal",
|
|
6
6
|
"main": "dist/index",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": " yarn clean && tsc && cp package.json dist/ && cp src/*.d.ts dist/",
|
|
9
|
+
"build": " yarn clean && tsc && cp package.json dist/ && cp src/*.d.ts dist/ && cp README.md dist/",
|
|
10
10
|
"clean": "rm -rf dist",
|
|
11
11
|
"lint": "eslint ./src --ext .ts && yarn prettier",
|
|
12
12
|
"prettier": "prettier --check \"./src/**/*.{ts,js,json}\"",
|
|
@@ -27,7 +27,7 @@ export default class SessionStorage {
|
|
|
27
27
|
}));
|
|
28
28
|
}
|
|
29
29
|
getStore(app, enabled, connectionString) {
|
|
30
|
-
if (enabled
|
|
30
|
+
if (enabled) {
|
|
31
31
|
logger.info('Using Redis session store', connectionString);
|
|
32
32
|
const client = createClient({
|
|
33
33
|
url: connectionString,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/session/session-storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,cAAc;IAC1B,SAAS,CAAC,GAAgB,EAAE,cAA2C;QAC5E,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7C,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QAE1B,GAAG,CAAC,GAAG,CACL,OAAO,CAAC;YACN,IAAI,EAAE,cAAc,CAAC,MAAM;YAC3B,MAAM,EAAE,KAAK;YACb,iBAAiB,EAAE,KAAK;YAC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