Skip to content

Commit d903799

Browse files
committed
replace uuid with node:crypto
1 parent e0152e9 commit d903799

File tree

6 files changed

+10
-40
lines changed

6 files changed

+10
-40
lines changed

internal/datastore/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"@aws-sdk/lib-dynamodb": "^3.858.0",
55
"@internal/helpers": "*",
66
"pino": "^9.7.0",
7-
"uuid": "^13.0.0",
87
"zod": "^4.1.11",
98
"zod-mermaid": "^1.0.9"
109
},

internal/datastore/src/__test__/supplier-repository.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Logger } from "pino";
2-
import { v4 as uuidv4 } from "uuid";
2+
import { randomUUID } from "node:crypto";
33
import {
44
DBContext,
55
createTables,
@@ -12,10 +12,10 @@ import { Supplier } from "../types";
1212

1313
function createSupplier(
1414
status: "ENABLED" | "DISABLED",
15-
apimId = uuidv4(),
15+
apimId = randomUUID(),
1616
): Omit<Supplier, "updatedAt"> {
1717
return {
18-
id: uuidv4(),
18+
id: randomUUID(),
1919
name: "Supplier One",
2020
apimId,
2121
status,
@@ -137,7 +137,7 @@ describe("SupplierRepository", () => {
137137
});
138138

139139
test("throws an error fetching a supplier by apimId when multiple exist", async () => {
140-
const apimId = "duplicate-apim-id";
140+
const apimId = randomUUID();
141141
const supplier1 = createSupplier("ENABLED", apimId);
142142
const supplier2 = createSupplier("DISABLED", apimId);
143143

internal/datastore/src/mi-repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb";
22
import { Logger } from "pino";
3-
import { v4 as uuidv4 } from "uuid";
3+
import { randomUUID } from "node:crypto";
44
import { MI, MISchema } from "./types";
55

66
export type MIRepositoryConfig = {
@@ -21,7 +21,7 @@ export class MIRepository {
2121
const now = new Date().toISOString();
2222
const miDb = {
2323
...mi,
24-
id: uuidv4(),
24+
id: randomUUID(),
2525
createdAt: now,
2626
updatedAt: now,
2727
ttl: Math.floor(Date.now() / 1000 + 60 * 60 * this.config.miTtlHours),

lambdas/api-handler/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"@internal/datastore": "*",
55
"@internal/helpers": "*",
66
"esbuild": "^0.25.11",
7-
"pino": "^9.7.0",
8-
"uuid": "13.0.0"
7+
"pino": "^9.7.0"
98
},
109
"devDependencies": {
1110
"@aws-sdk/s3-request-presigner": "^3.901.0",

lambdas/api-handler/src/mappers/error-mapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { APIGatewayProxyResult } from "aws-lambda";
22
import { NotFoundError, ValidationError } from "../errors";
33
import { buildApiError, ApiErrorCode, ApiErrorTitle, ApiError, ApiErrorStatus, ErrorResponse } from "../contracts/errors";
4-
import { v4 as uuid } from 'uuid';
4+
import { randomUUID } from 'node:crypto';
55
import { Logger } from "pino";
66

77
export function processError(error: unknown, correlationId: string | undefined, logger: Logger): APIGatewayProxyResult
@@ -34,7 +34,7 @@ function mapToErrorResponse(apiError: ApiError)
3434
}
3535

3636
function mapToApiError(code: ApiErrorCode, detail: string, correlationId: string | undefined): ApiError {
37-
const id = correlationId ? correlationId : uuid();
37+
const id = correlationId ? correlationId : randomUUID();
3838
return buildApiError({
3939
id,
4040
code,

package-lock.json

Lines changed: 1 addition & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)