Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1519 from Fdawgs/chore/tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Dec 2, 2023
2 parents 5f84b23 + 570f913 commit e276e2a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 56 deletions.
11 changes: 2 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = {
"plugin:promise/recommended",
"plugin:regexp/recommended",
"plugin:security/recommended",
"plugin:security-node/recommended",
"prettier",
],
overrides: [
Expand Down Expand Up @@ -40,14 +39,7 @@ module.exports = {
// Explicitly tell ESLint to parse JavaScript as CommonJS, as airbnb-base sets this to "modules" for ECMAScript
sourceType: "script",
},
plugins: [
"import",
"jsdoc",
"promise",
"regexp",
"security",
"security-node",
],
plugins: ["import", "jsdoc", "promise", "regexp", "security"],
root: true,
rules: {
"@eslint-community/eslint-comments/disable-enable-pair": "off",
Expand All @@ -57,6 +49,7 @@ module.exports = {
"jsdoc/check-syntax": "error",
"jsdoc/require-hyphen-before-param-description": "error",
"no-multiple-empty-lines": ["error", { max: 1 }],
"no-param-reassign": ["error", { props: false }],
"prefer-destructuring": ["error", { object: true, array: false }],
"promise/prefer-await-to-callbacks": "warn",
"promise/prefer-await-to-then": "warn",
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine
FROM node:20-alpine

# Workdir
WORKDIR /usr/app
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
> **Note**
> As of 2023-05-03 I am no longer employed by Somerset NHS Foundation Trust.
> However, this repository will continue to be maintained as it acts as
> a 'canary in the coalmine' for changes to Node and other dependencies.
> This repository is unmaintained as of 2023-05-03 as
> I am no longer employed by Somerset NHS Foundation Trust.
<a href="https://somersetft.nhs.uk/yeovilhospital/">
<img alttext="Somerset NHSFT logo" src="https://raw.githubusercontent.com/Fdawgs/yh-myydh-crud-api/main/docs/images/somerset-nhsft-logo-left-aligned-transparent-background.png" width="480" />
Expand Down
10 changes: 0 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"db:migrate": "node src/migrate.js",
"jest": "jest",
"jest:coverage": "jest --coverage",
"lint": "eslint . --cache --ext js,jsx,ts,tsx --ignore-path .gitignore",
"lint": "eslint . --cache --ext js,jsx --ignore-path .gitignore",
"lint:licenses": "node scripts/license-checker.js",
"lint:lockfile": "lockfile-lint -p package-lock.json -t npm -a npm -s -i",
"lint:prettier": "prettier . -c -u",
"lint:prettier:fix": "prettier . -w -u",
"prepare": "husky install",
"prepare": "husky install && npx playwright install firefox --with-deps",
"start": "node .",
"start:dev": "nodemon src/app.js | pino-pretty",
"test": "npm run lint && npm run jest",
Expand Down Expand Up @@ -91,7 +91,6 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-regexp": "^2.1.1",
"eslint-plugin-security": "^1.7.1",
"eslint-plugin-security-node": "^1.1.1",
"glob": "^10.3.10",
"husky": "^8.0.3",
"jest": "^29.7.0",
Expand Down
13 changes: 6 additions & 7 deletions src/plugins/clean-object/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ async function plugin(server) {
* @returns {object} cleaned object.
*/
function cleanObject(object = {}) {
const obj = object;
Object.keys(obj).forEach((key) => {
if (obj[key] && typeof obj[key] === "object") {
cleanObject(obj[key]);
} else if (obj[key] === null || obj[key] === undefined) {
delete obj[key];
Object.keys(object).forEach((key) => {
if (object[key] && typeof object[key] === "object") {
cleanObject(object[key]);
} else if (object[key] === null || object[key] === undefined) {
delete object[key];
}
});
return obj;
return object;
}

server.decorate("cleanObject", cleanObject);
Expand Down
36 changes: 13 additions & 23 deletions src/plugins/convert-date-param-operator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

const fp = require("fastify-plugin");

const operatorMap = {
ap: "=",
eb: "<",
eq: "=",
ge: ">=",
gt: ">",
le: "<=",
lt: "<",
ne: "!=",
sa: ">",
};

/**
* @author Frazer Smith
* @description Plugin that decorates Fastify instance with `convertDateParamOperator` function,
Expand All @@ -11,34 +23,12 @@ const fp = require("fastify-plugin");
async function plugin(server) {
/**
* @author Frazer Smith
* @author NextGen Healthcare
* @description Converts date param operator to corresponding value.
* @param {string} operator - Date param operator, in any letter case.
* @returns {string} converted date param operator.
*/
function convDateParamOperator(operator) {
switch (operator.toLowerCase()) {
case "ap":
return "=";
case "eb":
return "<";
case "eq":
return "=";
case "ge":
return ">=";
case "gt":
return ">";
case "le":
return "<=";
case "lt":
return "<";
case "ne":
return "!=";
case "sa":
return ">";
default:
return "=";
}
return operatorMap[operator.toLowerCase()] || "=";
}

server.decorate("convertDateParamOperator", convDateParamOperator);
Expand Down

0 comments on commit e276e2a

Please sign in to comment.