Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cb2-9045): update node version #57

Merged
merged 3 commits into from
Sep 13, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
with:
args: '--all-projects'
secrets:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.*
18.*
42,680 changes: 30,693 additions & 11,987 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"url": "https://github.com/dvsa/cvs-tsk-scheduled-operations.git"
},
"engines": {
"node": "14.*",
"npm": "5.6.0"
"node": "18.*",
"npm": "8.*"
},
"scripts": {
"start": "cross-env BRANCH=local serverless offline start",
Expand Down Expand Up @@ -57,7 +57,7 @@
"ts-jest": "^26.1.1",
"ts-node": "^8.5.4",
"tslint": "^6.0.0",
"typescript": "3.8.3"
"typescript": "4.4.4"
},
"dependencies": {
"@types/js-yaml": "^3.12.2",
Expand Down Expand Up @@ -92,4 +92,4 @@
"pre-push": "npm run prepush"
}
}
}
}
2 changes: 1 addition & 1 deletion serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ service: cvs-tsk-scheduled-operations

provider:
name: aws
runtime: nodejs14.x
runtime: nodejs18.x
tracing:
lambda: true
apiGateway: true
Expand Down
10 changes: 5 additions & 5 deletions src/utils/Configuration.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @ts-ignore
import * as yml from 'node-yaml';
import { Handler } from 'aws-lambda';
import { IConfig, IFunctionEvent, IInvokeConfig, INotifyConfig, ISecretConfig } from '../models';
import { ERRORS } from './Enums';
import SecretsManager, { GetSecretValueRequest, GetSecretValueResponse } from 'aws-sdk/clients/secretsmanager';
import { safeLoad } from 'js-yaml';
import * as AWSXray from 'aws-xray-sdk';
import { safeLoad } from 'js-yaml';
import * as yml from 'node-yaml';
import { IConfig, IFunctionEvent, IInvokeConfig, INotifyConfig, ISecretConfig } from '../models';
import { ERRORS } from './Enums';

class Configuration {
private static instance: Configuration;
Expand Down Expand Up @@ -137,7 +137,7 @@ class Configuration {
};
const resp: GetSecretValueResponse = await this.secretsClient.getSecretValue(req).promise();
try {
secret = await safeLoad(resp.SecretString as string);
secret = (await safeLoad(resp.SecretString as string)) as ISecretConfig;
} catch (e) {
throw new Error(ERRORS.SECRET_STRING_EMPTY);
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/decleration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'node-yaml';
15 changes: 6 additions & 9 deletions tests/unit/Configuration.unitTest.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Configuration } from '../../src/utils/Configuration';
import { IInvokeConfig } from '../../src/models';

import mockConfig from '../util/mockConfig';
import { Configuration } from '../../src/utils/Configuration';
import { ERRORS } from '../../src/utils/Enums';
import mockConfig from '../util/mockConfig';
jest.mock('aws-sdk/clients/secretsmanager');

describe('ConfigurationUtil', () => {
mockConfig();
console.log('here!?!?');
const config: Configuration = Configuration.getInstance();
console.log(config);
const badConfig: Configuration = new Configuration('../../tests/resources/badConfig.yml');
const branch = process.env.BRANCH;
const mockError = new Error(ERRORS.TEMPLATE_ID_ENV_VAR_NOT_EXIST);
Expand Down Expand Up @@ -163,13 +164,9 @@ describe('ConfigurationUtil', () => {

describe('getNotifyConfig', () => {
describe('when notify config not defined', () => {
it('should throw an error', () => {
it('should throw an error', async () => {
delete (config as any).config.notify;
try {
config.getNotifyConfig();
} catch (e) {
expect(e.message).toEqual(ERRORS.NOTIFY_CONFIG_NOT_DEFINED);
}
await expect(config.getNotifyConfig()).rejects.toThrow(ERRORS.NOTIFY_CONFIG_NOT_DEFINED);
});
});

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/handler.unitTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context } from 'aws-lambda';
import { handler } from '../../src/handler';
import { Context, Handler } from 'aws-lambda';
import { CleanupService } from '../../src/services/CleanupService';
import { Configuration } from '../../src/utils/Configuration';

Expand Down Expand Up @@ -117,7 +117,7 @@ describe('Handler', () => {
return;
});
} catch (e) {
expect(e.message).toEqual("Cannot read property 'body' of undefined");
expect(e.message).toEqual("Cannot read properties of undefined (reading 'body')");
}
});
});
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"resolveJsonModule": true,
"experimentalDecorators": true,
"pretty": true
"pretty": true,
"useUnknownInCatchVariables": false
}
}