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

Feature - Upgrading Fastify and NodeJS versions #310

Merged
merged 5 commits into from
Dec 17, 2024
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/jest-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '22.x'

- name: Cache Node.js modules
uses: actions/cache@v4
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ jobs:
linter:
name: Linter
runs-on: ubuntu-22.04 # todo: to prevent needing to run npm i we can have our own image where everything is installed
strategy:
matrix:
node-version: [18]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: '22.x'

- name: Install dependencies
run: npm i
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/push-release-tagged-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test-build-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand Down
23 changes: 15 additions & 8 deletions 00_Base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,35 @@
"author": "S44",
"license": "Apache-2.0",
"devDependencies": {
"@types/uuid": "9.0.3",
"@types/uuid": "9.0.7",
"@types/validator": "13.11.1",
"eslint": "8.48.0",
"json-schema-to-typescript": "12.0.0",
"json-schema-to-zod": "1.1.1",
"typescript": "5.0.4",
"typescript": "5.7.2",
"@types/jest": "29.5.12",
"jest": "29.7.0",
"ts-jest": "29.2.3",
"@faker-js/faker": "8.4.1"
"@faker-js/faker": "8.4.1",
"@eslint/js": "9.16.0",
"@types/eslint__js": "8.42.3",
"concurrently": "8.2.2",
"eslint": "9.16.0",
"eslint-config-prettier": "9.1.0",
"prettier": "3.2.5",
"typescript-eslint": "8.17.0",
"@types/deasync-promise": "1.0.0"
},
"dependencies": {
"@types/big.js": "6.2.1",
"ajv": "8.17.1",
"big.js": "6.2.1",
"class-transformer": "0.5.1",
"fastify": "4.22.2",
"@fastify/auth": "4.6.1",
"@fastify/type-provider-json-schema-to-ts": "2.2.2",
"fastify": "5.1.0",
"@fastify/auth": "5.0.1",
"@fastify/type-provider-json-schema-to-ts": "4.0.1",
"reflect-metadata": "0.1.13",
"tslog": "4.9.2",
"uuid": "9.0.0",
"uuid": "9.0.1",
"zod": "3.22.3"
}
}
10 changes: 6 additions & 4 deletions 00_Base/test/money/Money.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ describe('money', () => {
);

it('should fail when undefined amount', () => {
let amount: number;
expect(() => Money.of(amount, 'USD')).toThrow(`Amount has to be defined`);
const amount: number | undefined = undefined;
expect(() => Money.of(amount!, 'USD')).toThrow(
`Amount has to be defined`,
);
});

it.each([Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY])(
Expand All @@ -104,8 +106,8 @@ describe('money', () => {
);

it('should fail when undefined currency', () => {
let currency: string;
expect(() => Money.of('1.00', currency)).toThrow(
const currency: string | undefined = undefined;
expect(() => Money.of('1.00', currency!)).toThrow(
`Currency has to be defined`,
);
});
Expand Down
12 changes: 2 additions & 10 deletions 01_Data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,14 @@
"author": "S44",
"license": "Apache-2.0",
"devDependencies": {
"@types/bcrypt": "5.0.1",
"@types/uuid": "9.0.1",
"eslint": "8.48.0",
"typescript": "5.0.4"
"@types/bcrypt": "5.0.1"
},
"dependencies": {
"@citrineos/base": "1.6.0",
"@types/sequelize": "4.28.20",
"bcrypt": "5.1.1",
"pg": "8.11.3",
"pg-hstore": "2.3.4",
"sequelize-typescript": "2.1.6",
"tslog": "4.9.2",
"uuid": "9.0.0"
},
"engines": {
"node": ">=18"
"sequelize-typescript": "2.1.6"
}
}
18 changes: 4 additions & 14 deletions 02_Util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,15 @@
"license": "Apache-2.0",
"devDependencies": {
"@types/amqplib": "0.10.2",
"@types/bcrypt": "5.0.2",
"@types/json-schema-faker": "0.5.4",
"@types/jsrsasign": "10.5.14",
"@types/uuid": "9.0.1",
"eslint": "8.48.0",
"eslint-config-standard-with-typescript": "38.0.0",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-n": "16.0.2",
"eslint-plugin-promise": "6.1.1",
"typescript": "5.0.4"
"@types/jsrsasign": "10.5.14"
},
"dependencies": {
"@citrineos/base": "1.6.0",
"@citrineos/data": "1.6.0",
"@directus/sdk": "15.0.3",
"@fastify/swagger": "^8.0.0",
"@fastify/swagger-ui": "1.9.3",
"@fastify/swagger": "9.4.0",
"@fastify/swagger-ui": "5.2.0",
"@peculiar/webcrypto": "1.4.6",
"acme-client": "5.3.0",
"amqplib": "0.10.3",
Expand All @@ -46,8 +38,6 @@
"kafkajs": "2.2.4",
"mqtt": "5.1.2",
"pkijs": "3.0.16",
"redis": "4.6.6",
"tslog": "4.9.2",
"uuid": "9.0.0"
"redis": "4.6.6"
}
}
11 changes: 8 additions & 3 deletions 02_Util/src/certificate/client/acme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import { IChargingStationCertificateAuthorityClient } from './interface';
import { SystemConfig } from '@citrineos/base';
import * as acme from 'acme-client';
import { Client } from 'acme-client';
import { ILogObj, Logger } from 'tslog';
import fs from 'fs';
import { Client } from 'acme-client';
import {
createSignedCertificateFromCSR,
parseCertificateChainPem,
Expand Down Expand Up @@ -150,8 +150,13 @@ export class Acme implements IChargingStationCertificateAuthorityClient {
* @return {Promise<string>} - The signed certificate followed by sub CA in PEM format.
*/
async getCertificateChain(csrString: string): Promise<string> {
const [serverId, [certChain, subCAPrivateKey]] =
this._securityCertChainKeyMap.entries().next().value;
const nextEntry = this._securityCertChainKeyMap.entries().next().value;
if (!nextEntry) {
throw new Error(
'Failed to get certificate chain, securityCertChainKeyMap is empty',
);
}
const [serverId, [certChain, subCAPrivateKey]] = nextEntry;
this._logger.debug(
`Found certificate chain in server ${serverId}: ${certChain}`,
);
Expand Down
2 changes: 1 addition & 1 deletion 02_Util/test/certificate/client/Acme.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('ACME', () => {
let mockClient: jest.Mocked<Client>;

let systemConfig: SystemConfig;
let logger: Logger<ILogObj>;
const logger: Logger<ILogObj> | undefined = undefined;
let acme: Acme;

beforeAll(() => {
Expand Down
2 changes: 1 addition & 1 deletion 02_Util/test/certificate/client/Hubject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Hubject', () => {
},
},
} as any;
hubject = new Hubject(systemConfig, logger);
hubject = new Hubject(systemConfig, logger!);
});

describe('getSignedContractData', () => {
Expand Down
4 changes: 1 addition & 3 deletions 03_Modules/Certificates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
],
"license": "Apache-2.0",
"devDependencies": {
"@types/node-forge": "1.3.1",
"eslint": "8.48.0",
"typescript": "5.0.4"
"@types/node-forge": "1.3.1"
},
"dependencies": {
"@citrineos/base": "1.6.0",
Expand Down
14 changes: 1 addition & 13 deletions 03_Modules/Configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,9 @@
"ocpp_v201"
],
"license": "Apache-2.0",
"devDependencies": {
"@types/uuid": "9.0.7",
"@typescript-eslint/eslint-plugin": "6.5.0",
"@typescript-eslint/parser": "6.4.1",
"eslint": "8.48.0",
"eslint-config-standard-with-typescript": "38.0.0",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-n": "16.0.2",
"eslint-plugin-promise": "6.1.1",
"typescript": "5.0.4"
},
"dependencies": {
"@citrineos/base": "1.6.0",
"@citrineos/data": "1.6.0",
"@citrineos/util": "1.6.0",
"uuid": "9.0.1"
"@citrineos/util": "1.6.0"
}
}
4 changes: 0 additions & 4 deletions 03_Modules/EVDriver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"ocpp_v201"
],
"license": "Apache-2.0",
"devDependencies": {
"eslint": "8.48.0",
"typescript": "5.0.4"
},
"dependencies": {
"@citrineos/base": "1.6.0",
"@citrineos/data": "1.6.0",
Expand Down
4 changes: 0 additions & 4 deletions 03_Modules/Monitoring/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"ocpp_v201"
],
"license": "Apache-2.0",
"devDependencies": {
"eslint": "8.48.0",
"typescript": "5.0.4"
},
"dependencies": {
"@citrineos/base": "1.6.0",
"@citrineos/data": "1.6.0",
Expand Down
7 changes: 1 addition & 6 deletions 03_Modules/OcppRouter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@
],
"license": "Apache-2.0",
"devDependencies": {
"@types/node-forge": "1.3.1",
"@types/uuid": "9.0.1",
"eslint": "8.48.0",
"typescript": "5.0.4"
},
"dependencies": {
"@citrineos/base": "1.6.0",
"@citrineos/data": "1.6.0",
"@citrineos/util": "1.6.0",
"node-forge": "1.3.1",
"uuid": "9.0.0"
"node-forge": "1.3.1"
}
}
4 changes: 0 additions & 4 deletions 03_Modules/Reporting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"ocpp_v201"
],
"license": "Apache-2.0",
"devDependencies": {
"eslint": "8.48.0",
"typescript": "5.0.4"
},
"dependencies": {
"@citrineos/base": "1.6.0",
"@citrineos/data": "1.6.0",
Expand Down
4 changes: 0 additions & 4 deletions 03_Modules/SmartCharging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"ocpp_v201"
],
"license": "Apache-2.0",
"devDependencies": {
"eslint": "8.48.0",
"typescript": "5.0.4"
},
"dependencies": {
"@citrineos/base": "1.6.0",
"@citrineos/data": "1.6.0",
Expand Down
4 changes: 0 additions & 4 deletions 03_Modules/Tenant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"ocpp_v201"
],
"license": "Apache-2.0",
"devDependencies": {
"eslint": "8.48.0",
"typescript": "5.0.4"
},
"dependencies": {
"@citrineos/base": "1.6.0",
"@citrineos/data": "1.6.0",
Expand Down
7 changes: 0 additions & 7 deletions 03_Modules/Transactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
"ocpp_v201"
],
"license": "Apache-2.0",
"devDependencies": {
"eslint": "8.48.0",
"typescript": "5.0.4",
"@faker-js/faker": "8.4.1",
"jest": "29.7.0",
"@types/jest": "29.5.12"
},
"dependencies": {
"@citrineos/base": "1.6.0",
"@citrineos/data": "1.6.0",
Expand Down
4 changes: 2 additions & 2 deletions Server/deploy.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18 as build
FROM node:22 as build

WORKDIR /usr/local/apps/citrineos

Expand All @@ -8,7 +8,7 @@ RUN npm rebuild bcrypt --build-from-source

# The final stage, which copies built files and prepares the run environment
# Using a slim image to reduce the final image size
FROM node:18-slim
FROM node:22-slim
COPY --from=build /usr/local/apps/citrineos /usr/local/apps/citrineos

WORKDIR /usr/local/apps/citrineos
Expand Down
4 changes: 2 additions & 2 deletions Server/local.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18 as build
FROM node:22 as build

WORKDIR /usr/local/apps/citrineos

Expand All @@ -8,7 +8,7 @@ RUN npm rebuild bcrypt --build-from-source

# The final stage, which copies built files and prepares the run environment
# Using a slim image to reduce the final image size
FROM node:18-slim
FROM node:22-slim
COPY --from=build /usr/local/apps/citrineos /usr/local/apps/citrineos

WORKDIR /usr/local/apps/citrineos
Expand Down
Loading
Loading