Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions .eslintrc.json

This file was deleted.

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ pids
*.pid
*.seed

# Local env files
config/local.yaml

# Test reports
mochawesome-report

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

Expand Down
19 changes: 0 additions & 19 deletions .gitmessage

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.23.2
v24.15.0
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
language: node_js
node_js:
- "18.17.0"
- "24.15.0"
cache: yarn
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s
- export PATH="$HOME/.yarn/bin:$PATH"
install:
- npm install -g codecov
- yarn install
cache: yarn
script:
- yarn --version
- yarn --check-cache
Expand Down
5 changes: 5 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
approvedGitRepositories:
- "**"

compressionLevel: mixed

enableGlobalCache: false

enableScripts: true

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.17.1.cjs
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG PLATFORM=""
FROM hmctsprod.azurecr.io/base/node${PLATFORM}:18-alpine AS base
FROM hmctsprod.azurecr.io/base/node${PLATFORM}:24-alpine AS base

ENV PUPPETEER_SKIP_DOWNLOAD=true
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
Expand Down Expand Up @@ -30,7 +30,7 @@ COPY --chown=hmcts:hmcts package.json yarn.lock ./


# ---- Runtime Image ----
FROM hmctsprod.azurecr.io/base/node${PLATFORM}:18-alpine AS runtime
FROM hmctsprod.azurecr.io/base/node${PLATFORM}:24-alpine AS runtime
COPY --from=build $WORKDIR .

ENV PORT=3453
Expand Down
24 changes: 24 additions & 0 deletions Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,28 @@ withPipeline("nodejs", product, component) {
sh "yarn --check-cache"
}

afterAlways('test') {

publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "mochawesome-report",
reportFiles : "unit.html",
reportName : "Unit Test Report"
]
}

afterAlways('test:coverage') {

publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "coverage/lcov-report",
reportFiles : "index.html",
reportName : "Code Coverage Report"
]
}

}
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cd ccd-api-gateway

### Prerequisites

* [Node.js](https://nodejs.org/) >= v18.17.0
* [Node.js](https://nodejs.org/) >= v24.15.0
* [yarn](https://yarnpkg.com/)
* [Docker](https://www.docker.com)

Expand Down Expand Up @@ -61,6 +61,18 @@ To install dependencies please execute the following command:
yarn install
```

### Managing dependencies:
To update the versions in package.json use:
```bash
$ yarn upgrade-interactive
```
and choose the appropriate version for each dependency.

The jenkins pipeline will check dependency versions for vulnerabilities. If you wish to suppress the issues that the pipeline is looking for you can populate the "yarn-audit-known-issues" file by running:
```bash
$ yarn suppress-cve
```

### Running

Simply run:
Expand Down
4 changes: 2 additions & 2 deletions acb.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 1.0-preview-1
steps:

- id: pull-hmcts-base-amd64
cmd: docker pull --platform linux/amd64 hmctsprod.azurecr.io/base/node:18-alpine && docker tag hmctsprod.azurecr.io/base/node:18-alpine hmctsprod.azurecr.io/base/node/linux/amd64:18-alpine
cmd: docker pull --platform linux/amd64 hmctsprod.azurecr.io/base/node:24-alpine && docker tag hmctsprod.azurecr.io/base/node:24-alpine hmctsprod.azurecr.io/base/node/linux/amd64:24-alpine
when: ["-"]
retries: 3
retryDelay: 5
Expand Down Expand Up @@ -68,7 +68,7 @@ steps:
retryDelay: 5

- id: pull-hmcts-base-arm64
cmd: docker pull --platform linux/arm64 hmctsprod.azurecr.io/base/node:18-alpine && docker tag hmctsprod.azurecr.io/base/node:18-alpine hmctsprod.azurecr.io/base/node/linux/arm64:18-alpine
cmd: docker pull --platform linux/arm64 hmctsprod.azurecr.io/base/node:24-alpine && docker tag hmctsprod.azurecr.io/base/node:24-alpine hmctsprod.azurecr.io/base/node/linux/arm64:24-alpine
when:
- pull-hmcts-base-amd64
retries: 3
Expand Down
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const applyProxy = (app, config) => {
target: config.target,
changeOrigin: true,
onError: function onError(err, req, res) {
console.error(err);
logger.error(err);
mapFetchErrors(err, res);
},
logLevel: 'warn'
Expand Down
4 changes: 2 additions & 2 deletions app/address/address-lookup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const config = require('config');
const fetch = require('node-fetch');
const HttpsProxyAgent = require('https-proxy-agent');
const fetch = require('node-fetch').default;
const { HttpsProxyAgent } = require('https-proxy-agent');
const { Logger } = require('@hmcts/nodejs-logging');
const logger = Logger.getLogger('addressLookup');
const crypto = require('crypto');
Expand Down
2 changes: 1 addition & 1 deletion app/oauth2/access-token-request.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const config = require('config');
const fetch = require('node-fetch');
const fetch = require('node-fetch').default;
const { URL } = require('url');
const { Logger } = require('@hmcts/nodejs-logging');

Expand Down
2 changes: 1 addition & 1 deletion app/oauth2/logout-route.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const config = require('config');
const fetch = require('node-fetch');
const fetch = require('node-fetch').default;
const COOKIE_ACCESS_TOKEN = require('./oauth2-route').COOKIE_ACCESS_TOKEN;
const TOKEN_PLACEHOLDER = ':token';
const { userInfoCache } = require('../cache/cache-config');
Expand Down
6 changes: 3 additions & 3 deletions app/service/service-token-generator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const otp = require('otp');
const OTP = require('otp');
const config = require('config');
const jwtDecode = require('jwt-decode');
const { jwtDecode } = require('jwt-decode');
const fetch = require('../util/fetch');

const idamS2SUrl = config.get('idam.s2s_url');
Expand All @@ -17,7 +17,7 @@ const serviceTokenGenerator = () => {
&& currentTime < cache[serviceName].expiresAt) {
return Promise.resolve(cache[serviceName].token);
} else {
const oneTimePassword = otp({secret: secret}).totp();
const oneTimePassword = new OTP({ secret }).totp(currentTime);
const form = {
microservice: serviceName,
oneTimePassword
Expand Down
2 changes: 1 addition & 1 deletion app/util/fetch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const _fetch = require('node-fetch');
let _fetch = require('node-fetch').default;

const fetch = (...args) => {
return _fetch(...args)
Expand Down
69 changes: 39 additions & 30 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,56 @@ import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default defineConfig([{
extends: compat.extends("eslint:recommended"),

export default defineConfig([
{
ignores: [
'.yarn/**',
'eslint.config.mjs'
"**/config/*",
"**/node_modules/*",
"yarn.lock",
".yarn/**",
"yarn-audit-known-issues",
"**/*.properties",
],
},
{
files: ["**/*.js", "**/*.spec.js"],
extends: compat.extends("eslint:recommended"),

plugins: {
mocha,
mocha,
js,
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jquery,
...globals.mocha,
actor: true,
Feature: true,
Scenario: true,
codecept_helper: true,
},
globals: {
...globals.browser,
...globals.node,
...globals.jquery,
...globals.mocha,
actor: true,
Feature: true,
Scenario: true,
codecept_helper: true,
},

ecmaVersion: 2017,
sourceType: "module",
ecmaVersion: 2019,
sourceType: "module",
},

rules: {
"no-console": 0,
"linebreak-style": ["error", "unix"],
quotes: ["error", "single"],
semi: ["error", "always"],
"comma-dangle": ["error", "never"],
eqeqeq: "error",
"require-yield": "off",
"mocha/no-exclusive-tests": "error",
"no-console": "error",
"linebreak-style": ["error", "unix"],
quotes: ["error", "single"],
semi: ["error", "always"],
"comma-dangle": ["error", "never"],
eqeqeq: "error",
"require-yield": "off",
"mocha/no-exclusive-tests": "error",
},
}]);
},
]);
Loading