Skip to content

Commit

Permalink
feat: node 20 upgrade and triage unneccessary dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew2564 committed Sep 10, 2024
1 parent eb3169b commit df4a247
Show file tree
Hide file tree
Showing 21 changed files with 4,051 additions and 4,079 deletions.
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit "$1"
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run security-checks && npm run audit && npm run lint:fix && npm run format
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run test && npm run build && npm run test-i
2 changes: 1 addition & 1 deletion .npm-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.5.0
10.8.1
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.*
20.16
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ npm test

Please refer to the the [docs](./docs/README.md) for the API specification and samples of postman requests.

If the tests return a credentials error, check `~/.aws/credentials` has dummy values set up
If the tests return a credentials error, check `~/.aws/credentials` has dummy values set up

```
AWS_ACCESS_KEY_ID=some_value
AWS_SECRET_ACCESS_KEY=some_value
```
```
7,762 changes: 3,890 additions & 3,872 deletions package-lock.json

Large diffs are not rendered by default.

98 changes: 42 additions & 56 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,78 +9,64 @@
"type": "git",
"url": "git+https://github.com/dvsa/cvs-svc-app-logs.git"
},
"dependencies": {
"@aws-sdk/client-cloudwatch-logs": "3.540.0",
"moment": "^2.29.4"
},
"engines": {
"node": "18.*",
"npm": "9.*"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "npm run security-checks && npm run audit && npm run lint:fix && npm run format",
"pre-push": "npm run test && npm run build && npm run test-i"
}
},
"devDependencies": {
"@commitlint/cli": "17.7.1",
"@commitlint/config-conventional": "17.7.0",
"@types/aws-lambda": "^8.10.119",
"@types/jasmine": "^4.3.5",
"@types/node": "^20.5.0",
"@types/sinon": "^10.0.16",
"@types/supertest": "^2.0.12",
"audit-filter": "^0.5.0",
"aws-lambda-test-utils": "^1.3.0",
"aws-sdk-client-mock": "4.0.0",
"esbuild": "0.23.1",
"husky": "8.0.3",
"jasmine": "^5.1.0",
"jasmine-spec-reporter": "^7.0.0",
"json-schema-to-typescript": "^13.0.2",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"prettier": "3.0.1",
"rimraf": "^5.0.1",
"serverless": "^3.34.0",
"serverless-offline": "^12.0.4",
"serverless-webpack": "^5.13.0",
"sinon": "^15.2.0",
"sonar-scanner": "3.1.0",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-loader": "^9.4.4",
"ts-node": "^10.9.1",
"tslint": "^5.20.1",
"tslint-config-airbnb": "^5.11.2",
"typemoq": "^2.1.0",
"typescript": "^5.1.6",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"yamljs": "^0.3.0"
"node": "20.*",
"npm": "10.*"
},
"scripts": {
"clean": "rimraf build artefacts",
"clean": "rimraf build artefacts logs",
"compile": "rm -rf build && tsc",
"lint": "tslint --project tslint.json",
"format": "prettier --write .",
"build": "node_modules/typescript/bin/tsc --rootDir ./ --outDir .build --sourceMap false && npm run build:copy",
"build:copy": "find src -type f \\( -name \"*.yml\" -or -name \"*.json\" \\) | cpio -pdm .build && find specs -type f \\( -name \"*.yml\" -or -name \"*.json\" -or -name \"*.base64\" \\) | cpio -pdm .build",
"build": "ZIP_NAME=build ts-node package.ts",
"build:copy": "echo 'not yet implemented'",
"security-scan": "npm run security-checks",
"security-checks": "git secrets --scan && git log -p | scanrepo",
"start": "npm run compile && sls offline start --noPrependStageInUrl",
"start": "npm run build && sls offline start --noPrependStageInUrl",
"test": "nyc npm run test:compile",
"test:compile": "npm run compile && jasmine",
"test-i": "echo 'not yet implemented'",
"test:integration": "npm run compile && jasmine build/spec/logs-service.spec.js",
"compile-no-emit": "tsc --noEmit -p .",
"lint:fix": "tslint --fix -p ./",
"sonar-scanner": "sonar-scanner",
"audit": "npm audit --prod",
"audit": "npm audit --omit=dev",
"package": "ts-node package.ts && cd ${ZIP_NAME:-'logs'}; zip -r ../${ZIP_NAME:-'logs'}.zip *",
"tools-setup": "echo 'Nothing to do'"
"tools-setup": "echo 'Nothing to do'",
"prepare": "husky"
},
"dependencies": {
"@aws-sdk/client-cloudwatch-logs": "^3.645.0"
},
"devDependencies": {
"@commitlint/cli": "19.4.1",
"@commitlint/config-conventional": "19.4.1",
"@types/aws-lambda": "^8.10.145",
"@types/jasmine": "^5.1.4",
"@types/node": "^20.16.5",
"@types/supertest": "^2.0.12",
"aws-lambda-test-utils": "^1.3.0",
"aws-sdk-client-mock": "^4.0.1",
"esbuild": "0.23.1",
"husky": "^9.1.5",
"jasmine": "^5.3.0",
"jasmine-spec-reporter": "^7.0.0",
"json-schema-to-typescript": "^15.0.2",
"npm-run-all": "^4.1.5",
"nyc": "^17.0.0",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"serverless": "^3.39.0",
"serverless-offline": "^13.8.0",
"sonar-scanner": "3.1.0",
"source-map-support": "^0.5.21",
"supertest": "^7.0.0",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tslint": "^6.1.3",
"typemoq": "^2.1.0",
"typescript": "5.5.4",
"yamljs": "^0.3.0"
},
"nyc": {
"require": [
Expand Down
9 changes: 2 additions & 7 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ service: cvs-svc-app-logs

provider:
name: aws
runtime: nodejs18.x
runtime: nodejs20.x
lambdaHashingVersion: "20201221"
region: ${env:AWS_PROVIDER_REGION, 'local'}

Expand All @@ -11,16 +11,11 @@ package:

functions:
postLogs:
handler: src/functions/postLogs/framework/handler.handler
handler: build/handler.handler
events:
- http:
path: "logs"
method: post

custom:
webpack:
webpackConfig: "webpack-sls-offline.config.js"

plugins:
- serverless-webpack
- serverless-offline
2 changes: 1 addition & 1 deletion spec/helpers/integration-test-lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const startSlsOffline = (done: any) => {
slsOfflineProcess.stdout?.pipe(process.stdout);

console.log(
`Serverless: Offline started with PID : ${slsOfflineProcess.pid}`
`Serverless: Offline started with PID : ${slsOfflineProcess.pid}`,
);

slsOfflineProcess.stdout?.on("data", (data) => {
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ jasmine.getEnv().clearReporters();
jasmine.getEnv().addReporter(
new SpecReporter({
customProcessors: [CustomProcessor],
})
}),
);
2 changes: 1 addition & 1 deletion src/common/application/utils/createResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Response from "../api/Response";
export default (
body: {},
statusCode = 200,
reqHeaders: { [id: string]: string } = {}
reqHeaders: { [id: string]: string } = {},
): Response => {
const accessControlAllowOriginHeader = {
"Access-Control-Allow-Origin": "*", // Required for CORS support to work
Expand Down
6 changes: 3 additions & 3 deletions src/functions/postLogs/application/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class Logger {
await this.logDelegate(logEvents);
} catch (e) {
console.error(
"Error occurred while attempting to log events to logging system:"
"Error occurred while attempting to log events to logging system:",
);
console.error(e);
}
Expand All @@ -42,7 +42,7 @@ export default class Logger {
async log(message: string, logLevel: LogLevel, logData?: Bag): Promise<void> {
const eventMessage = Object.assign(
{ message, logLevel, loggerName: this.loggerName },
logData
logData,
);

await this.logEvents([
Expand All @@ -60,7 +60,7 @@ export default class Logger {
description,
value,
service: "logs-service",
})
}),
);
}
}
22 changes: 11 additions & 11 deletions src/functions/postLogs/application/__tests__/Logger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("Logger", () => {
// ASSERT
moqLogDelegate.verify(
(x) => x(It.is<LogEvent[]>((evnts) => evnts.length === 3)),
Times.once()
Times.once(),
);
});

Expand All @@ -39,17 +39,17 @@ describe("Logger", () => {
moqConsoleError.verify(
(x) =>
x("Error occurred while attempting to log events to logging system:"),
Times.once()
Times.once(),
);

moqConsoleError.verify(
(x) =>
x(
It.is<Error>(
(e) => e.message === "example external logging system error"
)
(e) => e.message === "example external logging system error",
),
),
Times.once()
Times.once(),
);
});
});
Expand All @@ -70,10 +70,10 @@ describe("Logger", () => {
evnts[0].timestamp <= new Date().getTime() &&
/test log message/.test(evnts[0].message) &&
/info/.test(evnts[0].message) &&
/1234/.test(evnts[0].message)
)
/1234/.test(evnts[0].message),
),
),
Times.once()
Times.once(),
);
});

Expand All @@ -90,10 +90,10 @@ describe("Logger", () => {
evnts.length === 1 &&
/test log message/.test(evnts[0].message) &&
!/info/.test(evnts[0].message) &&
/other/.test(evnts[0].message)
)
/other/.test(evnts[0].message),
),
),
Times.once()
Times.once(),
);
});
});
Expand Down
Loading

0 comments on commit df4a247

Please sign in to comment.