diff --git a/.woodpecker/.build.yml b/.woodpecker/.build.yml index c50d477..807fb97 100644 --- a/.woodpecker/.build.yml +++ b/.woodpecker/.build.yml @@ -10,5 +10,7 @@ steps: matrix: BUN_VERSION: - - 1.0.25 - - 1.0.26 \ No newline at end of file + - 1.0.30 + - 1.0.31 + - 1.0.32 + - 1.0.33 \ No newline at end of file diff --git a/.woodpecker/.lint.yml b/.woodpecker/.lint.yml index d6fbe08..5e06448 100644 --- a/.woodpecker/.lint.yml +++ b/.woodpecker/.lint.yml @@ -3,7 +3,7 @@ when: steps: lint: - image: oven/bun:1.0.26-slim + image: oven/bun:1.0.33-slim commands: - bun install - bun run ci diff --git a/.woodpecker/.test.yml b/.woodpecker/.test.yml index 0ba051e..5ea367c 100644 --- a/.woodpecker/.test.yml +++ b/.woodpecker/.test.yml @@ -12,8 +12,9 @@ steps: matrix: BUN_VERSION: - - 1.0.25 - - 1.0.26 + - 1.0.31 + - 1.0.32 + - 1.0.33 services: nats: diff --git a/biome.json b/biome.json index 13fdba5..0473834 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", + "$schema": "https://biomejs.dev/schemas/1.6.1/schema.json", "organizeImports": { "enabled": true }, diff --git a/bun.lockb b/bun.lockb index 5bb4e7f..c576a94 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 95de1ba..ccf7497 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "build": "tsc --project tsconfig.build.json" }, "devDependencies": { - "@biomejs/biome": "1.5.3", + "@biomejs/biome": "1.6.1", "@types/bun": "latest", "typescript": "^5.0.0" }, diff --git a/src/adaptors/nats.ts b/src/adaptors/nats.ts index 0930ba3..f773860 100644 --- a/src/adaptors/nats.ts +++ b/src/adaptors/nats.ts @@ -52,6 +52,7 @@ export default class NatsAdaptor implements Adaptor { } async stop(): Promise { + this.sub?.unsubscribe(); await this.nc?.drain(); } } diff --git a/src/service.ts b/src/service.ts index 1d95ff4..e57d05f 100644 --- a/src/service.ts +++ b/src/service.ts @@ -1,4 +1,4 @@ -import { z } from "zod"; +import type { z } from "zod"; import type Adaptor from "./adaptors/adaptor"; import { RequestError } from "./error"; import { @@ -36,6 +36,7 @@ export default class Service { async (rawReq) => { const rawReqJson = JSON.parse(rawReq); const internalRequestJson = InternalRequestSchema.safeParse(rawReqJson); + if (!internalRequestJson.success) { return JSON.stringify({ statusCode: 400, @@ -51,12 +52,14 @@ export default class Service { if (internalRequest.data && schema) { const validate = schema.safeParse(internalRequest.data); + if (!validate.success) { return JSON.stringify({ statusCode: 400, data: validate.error, } satisfies InternalResponse); } + req.data = validate.data; } @@ -75,6 +78,7 @@ export default class Service { data: err.message, } satisfies InternalResponse); } + return JSON.stringify({ statusCode: 500, data: "unknow error apend", diff --git a/tsconfig.json b/tsconfig.json index dcd8fc5..5adda45 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,22 +1,22 @@ { - "compilerOptions": { - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, + "compilerOptions": { + "lib": ["ESNext"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, - /* Linting */ - "skipLibCheck": true, - "strict": true, - "noFallthroughCasesInSwitch": true, - "forceConsistentCasingInFileNames": true - } + /* Linting */ + "skipLibCheck": true, + "strict": true, + "noFallthroughCasesInSwitch": true, + "forceConsistentCasingInFileNames": true + } }