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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
infrastructure
kubernetes
node_modules
mochawesome-report
Jenkinsfile*
README.md
!.yarnrc.yml
Expand Down
4 changes: 0 additions & 4 deletions .eslintrc.yml

This file was deleted.

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

# Directory for mochawesome reports
mochawesome-report

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

Expand All @@ -30,6 +33,8 @@ coverage
build/Release
acb.yaml

package-lock.json

# Dependency directories
node_modules
jspm_packages
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.20.2
v24.15.0
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "20.20.2"
- "24.15.0"
cache: yarn
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hmctsprod.azurecr.io/base/node:20-alpine AS base
FROM hmctsprod.azurecr.io/base/node:24-alpine AS base

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


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

EXPOSE 3460
24 changes: 24 additions & 0 deletions Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,30 @@ withPipeline(type, 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"
]
}

afterAlways('smoketest:preview') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/BEFTA Report for Smoke Tests/**/*'
publishHTML target: [
Expand Down
4 changes: 2 additions & 2 deletions acb.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ steps:
privileged: true

- id: pull-hmcts-base-amd64
cmd: docker image rm -f hmctsprod.azurecr.io/base/node:20-alpine || true && docker pull --platform linux/amd64 hmctsprod.azurecr.io/base/node:20-alpine
cmd: docker image rm -f hmctsprod.azurecr.io/base/node:24-alpine || true && docker pull --platform linux/amd64 hmctsprod.azurecr.io/base/node:24-alpine
when: ["-"]
retries: 3
retryDelay: 5
Expand Down Expand Up @@ -71,7 +71,7 @@ steps:
retryDelay: 5

- id: pull-hmcts-base-arm64
cmd: docker image rm -f hmctsprod.azurecr.io/base/node:20-alpine || true && docker pull --platform linux/arm64 hmctsprod.azurecr.io/base/node:20-alpine
cmd: docker image rm -f hmctsprod.azurecr.io/base/node:24-alpine || true && docker pull --platform linux/arm64 hmctsprod.azurecr.io/base/node:24-alpine
when:
- pull-hmcts-base-amd64
retries: 3
Expand Down
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ app.disable(poweredByHeader);
appHealth.disable(poweredByHeader);

const healthConfig = {
checks: {},
checks: {}
};
healthcheck.addTo(appHealth, healthConfig);
app.use(appHealth);
Expand Down Expand Up @@ -69,7 +69,7 @@ app.use((err, req, res, next) => {

res.status(err.status || 500);
res.json({
message: err.message,
message: err.message
});
});

Expand Down
2 changes: 1 addition & 1 deletion app/cache/cache-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ const CacheService = require('./cache-service');
const userInfoCache = new CacheService('UserInfoCache', config.get('cache.user_info_ttl'), config.get('cache.user_info_check_period'));

module.exports = {
userInfoCache,
userInfoCache
};
6 changes: 3 additions & 3 deletions app/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const activityHealth = healthcheck.configure({
redis.ping(),
new Promise((_, reject) => {
setTimeout(reject, config.get('app.requestTimeoutSec') * 1000);
}),
})
])
.then(() => healthcheck.up())
.catch(() => healthcheck.down())),
},
.catch(() => healthcheck.down()))
}
});

module.exports = activityHealth;
2 changes: 1 addition & 1 deletion app/job/store-cleanup-job.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const scanExistingCasesKeys = (f) => {
// only returns keys following the pattern
match: `${REDIS_ACTIVITY_KEY_PREFIX}case:*`,
// returns approximately 100 elements per call
count: 100,
count: 100
});
const keys = [];
stream.on('data', (resultKeys) => {
Expand Down
2 changes: 1 addition & 1 deletion app/redis/redis-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const redis = new Redis({
tls: config.get('redis.ssl'),
keyPrefix: config.get('redis.keyPrefix'),
// log unhandled redis errors
showFriendlyErrorStack: ENV === 'test' || ENV === 'dev',
showFriendlyErrorStack: ENV === 'test' || ENV === 'dev'
});

/* redis pipeline returns a reply of the form [[op1error, op1result], [op2error, op2result], ...].
Expand Down
4 changes: 2 additions & 2 deletions app/routes/activity-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const validateRequest = require('./validate-request');
const router = express.Router();

module.exports = (activityService, config) => {
const addActivity = require('./add-activity')(activityService); // eslint-disable-line global-require
const getActivities = require('./get-activities')(activityService); // eslint-disable-line global-require
const addActivity = require('./add-activity')(activityService);
const getActivities = require('./get-activities')(activityService);

const toMillis = (timeSec) => timeSec * 1000;

Expand Down
3 changes: 1 addition & 2 deletions app/routes/validate-request.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const validateRequest = (schema, value) => (req, res, next) => {
const { error } = schema.validate(value);
const valid = error == null;
const valid = error === null || error === undefined;
if (valid) {
next();
} else {
const { details } = error;
const message = details.map((i) => i.message).join(',');
console.log('error', message);
res.status(400).json({ error: message });
}
};
Expand Down
2 changes: 1 addition & 1 deletion app/security/cors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const createWhitelistValidator = (val) => {
const corsOptions = {
allowOrigin: createWhitelistValidator,
allowCredentials: true,
allowMethods: config.get('security.cors_origin_methods'),
allowMethods: config.get('security.cors_origin_methods')
};

const handleCors = (req, res, next) => {
Expand Down
4 changes: 2 additions & 2 deletions app/service/activity-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const debug = require('debug')('ccd-case-activity-api:activity-service');
module.exports = (config, redis, ttlScoreGenerator) => {
const redisActivityKeys = {
view: (caseId) => `case:${caseId}:viewers`,
edit: (caseId) => `case:${caseId}:editors`,
edit: (caseId) => `case:${caseId}:editors`
};

const addActivity = (caseId, user, activity) => {
Expand All @@ -23,7 +23,7 @@ module.exports = (config, redis, ttlScoreGenerator) => {

return redis.pipeline([
storeUserActivity(),
storeUserDetails(),
storeUserDetails()
]).exec();
};

Expand Down
6 changes: 3 additions & 3 deletions app/user/auth-checker-user-only-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ const mapFetchErrors = (error, next) => {
next({
error: 'Bad Gateway',
status: 502,
message: error.message,
message: error.message
});
} else {
next({
error: 'Internal Server Error',
status: 500,
message: error.message,
message: error.message
});
}
};
Expand All @@ -41,7 +41,7 @@ const authCheckerUserOnlyFilter = (req, res, next) => {
mapFetchErrors(error, next);
} else {
logger.warn('Unsuccessful user authentication', error);
error.status = error.status || 401; // eslint-disable-line no-param-reassign
error.status = error.status || 401;
next(error);
}
});
Expand Down
2 changes: 1 addition & 1 deletion app/user/cached-user-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const jwtUtil = require('../util/jwt');
// NB: names match the user-resolver which this module mirrors
const getUserDetails = (jwt) => userInfoCache.getOrElseUpdate(
jwtUtil.removeBearer(jwt),
() => userResolver.getUserDetails(jwt),
() => userResolver.getUserDetails(jwt)
);

exports.getUserDetails = getUserDetails;
6 changes: 3 additions & 3 deletions app/user/user-request-authorizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ const AUTHORIZATION = 'Authorization';
const ERROR_TOKEN_MISSING = {
error: 'Bearer token missing',
status: 401,
message: 'You are not authorized to access this resource',
message: 'You are not authorized to access this resource'
};
const ERROR_UNAUTHORISED_ROLE = {
error: 'Unauthorised role',
status: 403,
message: 'You are not authorized to access this resource',
message: 'You are not authorized to access this resource'
};
const ERROR_UNAUTHORISED_USER_ID = {
error: 'Unauthorised user',
status: 403,
message: 'You are not authorized to access this resource',
message: 'You are not authorized to access this resource'
};

const authorizeRoles = (request, user) => new Promise((resolve, reject) => {
Expand Down
4 changes: 2 additions & 2 deletions app/user/user-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const jwtUtil = require('../util/jwt');

const getUserDetails = (jwt) => fetch(`${config.get('idam.base_url')}/o/userinfo`, {
headers: {
Authorization: jwtUtil.addBearer(jwt),
},
Authorization: jwtUtil.addBearer(jwt)
}
})
.then((res) => res.json());

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 nodeFetch = require('node-fetch');
const nodeFetch = require('node-fetch').default;

const fetch = (...args) => nodeFetch(...args)
.then((res) => {
Expand Down
59 changes: 49 additions & 10 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from "eslint/config";
import mocha from "eslint-plugin-mocha";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
Expand All @@ -8,18 +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("airbnb-base"),
export default defineConfig([
{
ignores: [
"**/config/*",
"**/node_modules/*",
"yarn.lock",
".yarn/**",
"yarn-audit-known-issues",
"**/*.properties",
],
},
{
files: ["**/*.js", "**/*.spec.js"],
extends: compat.extends("eslint:recommended"),

plugins: {
mocha,
js,
},

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

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

rules: {
"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