From e34ba9a239c2e91615adf6e710813f75d4b04cf2 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 20 Feb 2025 10:44:28 +0700 Subject: [PATCH] chore: update deps and api docs config --- package.json | 2 +- pnpm-lock.yaml | 26 +++++++++++++------------- src/app.ts | 22 +++++++++++++--------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index e558665..a0f170b 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@elastic/elasticsearch": "^8.17.0", "@fast-csv/parse": "^5.0.2", "@prisma/client": "^6.3.0", - "@scalar/express-api-reference": "^0.4.173", + "@scalar/express-api-reference": "^0.4.182", "@tsoa/runtime": "^6.6.0", "@types/morgan": "^1.9.9", "cors": "^2.8.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c4c2450..4fe90d1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,8 +18,8 @@ importers: specifier: ^6.3.0 version: 6.3.0(prisma@6.3.0(typescript@5.7.2))(typescript@5.7.2) '@scalar/express-api-reference': - specifier: ^0.4.173 - version: 0.4.173 + specifier: ^0.4.182 + version: 0.4.182 '@tsoa/runtime': specifier: ^6.6.0 version: 6.6.0 @@ -366,16 +366,16 @@ packages: '@prisma/prisma-schema-wasm@5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59': resolution: {integrity: sha512-+zUI7NQDXfcNnU8HgrAj4jRMv8yRfITLzcfv0Urf0adKimM+hkkVG4rX38i9zWMlxekkEBw7NLFx3Gxxy8d3iQ==} - '@scalar/express-api-reference@0.4.173': - resolution: {integrity: sha512-C/s+rdImUb7gLbYRH6ICZjVPV8SHHMwJQ/Fiu6fVGomPldi0fpTDMaXH+9jRIlTm3LR6ACl/OlH7MXcPPRaFSA==} + '@scalar/express-api-reference@0.4.182': + resolution: {integrity: sha512-T8y+/FM24H1C13GMDkjmM62obEhfGclIPwR2tn2JK+TY6LhKuHAF0xPzaBkfiRjlSEnrJigJSJxb8lwGxHWr9A==} engines: {node: '>=18'} - '@scalar/openapi-types@0.1.5': - resolution: {integrity: sha512-6geH9ehvQ/sG/xUyy3e0lyOw3BaY5s6nn22wHjEJhcobdmWyFER0O6m7AU0ZN4QTjle/gYvFJOjj552l/rsNSw==} + '@scalar/openapi-types@0.1.7': + resolution: {integrity: sha512-oOTG3JQifg55U3DhKB7WdNIxFnJzbPJe7rqdyWdio977l8IkxQTVmObftJhdNIMvhV2K+1f/bDoMQGu6yTaD0A==} engines: {node: '>=18'} - '@scalar/types@0.0.25': - resolution: {integrity: sha512-sGnOFnfiSn4o23rklU/jrg81hO+630bsFIdHg8MZ/w2Nc6IoUwARA2hbe4d4Fg+D0KBu40Tan/L+WAYDXkTJQg==} + '@scalar/types@0.0.33': + resolution: {integrity: sha512-4mQYkQJO0HHaoFd8Z+vSdQAvYcCJ2bRLN9ewE+GneB8kvoLG/oM3ynroqzGQdoytH8BmhnJwD3aEUagfbK2x5g==} engines: {node: '>=18'} '@swc/helpers@0.5.15': @@ -3123,15 +3123,15 @@ snapshots: '@prisma/prisma-schema-wasm@5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59': {} - '@scalar/express-api-reference@0.4.173': + '@scalar/express-api-reference@0.4.182': dependencies: - '@scalar/types': 0.0.25 + '@scalar/types': 0.0.33 - '@scalar/openapi-types@0.1.5': {} + '@scalar/openapi-types@0.1.7': {} - '@scalar/types@0.0.25': + '@scalar/types@0.0.33': dependencies: - '@scalar/openapi-types': 0.1.5 + '@scalar/openapi-types': 0.1.7 '@unhead/schema': 1.11.14 '@swc/helpers@0.5.15': diff --git a/src/app.ts b/src/app.ts index d902b1e..bf90641 100644 --- a/src/app.ts +++ b/src/app.ts @@ -6,7 +6,6 @@ import morgan from "./middlewares/morgan"; import { RegisterRoutes } from "./routes"; import { initEmploymentOffice, initThailandAreaDatabase } from "./utils/thailand-area"; import { initFirstAdmin } from "./utils/database"; -import { apiReference } from "@scalar/express-api-reference"; import { initSchedule } from "./services/schedule"; const APP_HOST = process.env.APP_HOST || "0.0.0.0"; @@ -24,8 +23,7 @@ const APP_PORT = +(process.env.APP_PORT || 3000); const originalSend = app.response.json; app.response.json = function (body: unknown) { - this.app.locals.response = body; - return originalSend.call(this, body); + return originalSend.call(this, (this.app.locals.response = body)); }; app.use(cors()); @@ -36,12 +34,18 @@ const APP_PORT = +(process.env.APP_PORT || 3000); app.use("/", express.static("static")); app.use( "/api-docs", - apiReference({ - theme: "kepler", - layout: "classic", - spec: { url: "/api/openapi" }, - cdn: "https://cdn.jsdelivr.net/npm/@scalar/api-reference@1.25.74", - }), + await import("@scalar/express-api-reference").then(({ apiReference }) => + apiReference({ + theme: "kepler", + layout: "classic", + + hideModels: true, + hideClientButton: true, + customCss: `.endpoint-label-name { display: none }`, + + spec: { url: "/api/openapi" }, + }), + ), ); RegisterRoutes(app);