mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat(api): add Scalar docs route and install dependency
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
"@fastify/multipart": "^9.0.0",
|
||||
"@fastify/rate-limit": "^10.2.0",
|
||||
"@fastify/static": "^8.1.0",
|
||||
"@scalar/fastify-api-reference": "^1.49.5",
|
||||
"@stirling-image/ai": "workspace:*",
|
||||
"@stirling-image/image-engine": "workspace:*",
|
||||
"@stirling-image/shared": "workspace:*",
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import scalarPlugin from "@scalar/fastify-api-reference";
|
||||
import type { FastifyInstance } from "fastify";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
export async function docsRoutes(app: FastifyInstance): Promise<void> {
|
||||
const specPath = resolve(__dirname, "../openapi.yaml");
|
||||
const specContent = readFileSync(specPath, "utf-8");
|
||||
|
||||
app.get("/api/v1/openapi.yaml", async (_request, reply) => {
|
||||
reply.type("text/yaml").send(specContent);
|
||||
});
|
||||
|
||||
await app.register(scalarPlugin, {
|
||||
routePrefix: "/api/docs",
|
||||
configuration: {
|
||||
spec: {
|
||||
content: specContent,
|
||||
},
|
||||
theme: "default",
|
||||
customCss: `
|
||||
:root {
|
||||
--scalar-color-1: #09090b;
|
||||
--scalar-color-2: #3f3f46;
|
||||
--scalar-color-3: #71717a;
|
||||
--scalar-color-accent: #2563eb;
|
||||
--scalar-background-1: #ffffff;
|
||||
--scalar-background-2: #f4f4f5;
|
||||
--scalar-background-3: #e4e4e7;
|
||||
--scalar-border-color: #e4e4e7;
|
||||
--scalar-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
}
|
||||
`,
|
||||
hideDownloadButton: false,
|
||||
hideTestRequestButton: true,
|
||||
hiddenClients: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
Generated
+129
@@ -83,6 +83,9 @@ importers:
|
||||
'@fastify/static':
|
||||
specifier: ^8.1.0
|
||||
version: 8.3.0
|
||||
'@scalar/fastify-api-reference':
|
||||
specifier: ^1.49.5
|
||||
version: 1.49.5
|
||||
'@stirling-image/ai':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/ai
|
||||
@@ -2050,6 +2053,38 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@scalar/core@0.4.5':
|
||||
resolution: {integrity: sha512-W+GN4oInzUWJzS2uwTQpRWl4uCOcnyXyu2zS05jApWUO5Pn7VSh9JSlqDz0nKVMaizWyjblJqocirlGo71pDPA==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@scalar/fastify-api-reference@1.49.5':
|
||||
resolution: {integrity: sha512-ujYwxVBz23DqCi4phOkPYli6c2kSiqwhAxp6Hm6vycZdE0RWNMBhJc8PR+lligXc9ikHxbQozcQImtkn3M5htQ==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@scalar/helpers@0.4.2':
|
||||
resolution: {integrity: sha512-IrgrGVSahCfYDNWITazz4Q1BOndp5eEzlimRkfxiYn++KqeWyLfALyym1omqcdKGYtiSx1KIbKaUJL9vkjaN7w==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@scalar/json-magic@0.12.4':
|
||||
resolution: {integrity: sha512-ZsJM+y9SOVjRL+g9Tr/jFEodcYPfHSt5ZRrpbeGDK71yTvSZw41A3UJ7Bg+RXM8JJWRYcJkYVkzrmbb/ig7qlA==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@scalar/openapi-parser@0.25.6':
|
||||
resolution: {integrity: sha512-tIc0SOjjKQOqFeKiU84B12Ltbr+9C6LFkP4dOzn9r/gAcE4ARquJ5Ue4xJbtgvMVPByTOXTo5F9Y1WgTU4HxpQ==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@scalar/openapi-types@0.6.1':
|
||||
resolution: {integrity: sha512-P1RvyTFN0vRSL136OqWjlZfSFjY9JoJfuD6LM1mIjoocfwmqX3WuzsFEFX6hAeeDlTh6gjbiy+OdhSee8GFfSA==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@scalar/openapi-upgrader@0.2.2':
|
||||
resolution: {integrity: sha512-bIFfdiDyHVcUQHY2iTsmtDwhUHX09F/xCM5cGp1cVSbbahMiMmdKaxf/PnNsGSR5wGHfYknV1X1KS1brtXxrnw==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@scalar/types@0.7.5':
|
||||
resolution: {integrity: sha512-LUR/+nNpHfMbGCqTnrzyRlgRTC4FMyyqwCYCFYVs57gkEWzmXnrx+r3+igrWtuZoK/Hsr+ffFMzbBvmxnTFH7g==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
'@sec-ant/readable-stream@0.4.1':
|
||||
resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==}
|
||||
|
||||
@@ -2535,6 +2570,14 @@ packages:
|
||||
resolution: {integrity: sha512-gOsf2YwSlleG6IjRYG2A7k0HmBMEo6qVNk9Bp/EaLgAJT5ngH6PXbqa4ItvnEwCm/velL5jAnQgsHsWnjhGmvw==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
ajv-draft-04@1.0.0:
|
||||
resolution: {integrity: sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==}
|
||||
peerDependencies:
|
||||
ajv: ^8.5.0
|
||||
peerDependenciesMeta:
|
||||
ajv:
|
||||
optional: true
|
||||
|
||||
ajv-formats@3.0.1:
|
||||
resolution: {integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==}
|
||||
peerDependencies:
|
||||
@@ -3306,6 +3349,9 @@ packages:
|
||||
fast-uri@3.1.0:
|
||||
resolution: {integrity: sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==}
|
||||
|
||||
fastify-plugin@4.5.1:
|
||||
resolution: {integrity: sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ==}
|
||||
|
||||
fastify-plugin@5.1.0:
|
||||
resolution: {integrity: sha512-FAIDA8eovSt5qcDgcBvDuX/v0Cjz0ohGhENZ/wpc3y+oZCY2afZ9Baqql3g/lC+OHRnciQol4ww7tuthOb9idw==}
|
||||
|
||||
@@ -3458,6 +3504,9 @@ packages:
|
||||
github-from-package@0.0.0:
|
||||
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
|
||||
|
||||
github-slugger@2.0.0:
|
||||
resolution: {integrity: sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==}
|
||||
|
||||
glob@10.5.0:
|
||||
resolution: {integrity: sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==}
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
@@ -3756,6 +3805,10 @@ packages:
|
||||
jsonfile@6.2.0:
|
||||
resolution: {integrity: sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==}
|
||||
|
||||
jsonpointer@5.0.1:
|
||||
resolution: {integrity: sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
jsqr@1.4.0:
|
||||
resolution: {integrity: sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A==}
|
||||
|
||||
@@ -3763,6 +3816,10 @@ packages:
|
||||
resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==}
|
||||
engines: {node: '>= 0.6.3'}
|
||||
|
||||
leven@4.1.0:
|
||||
resolution: {integrity: sha512-KZ9W9nWDT7rF7Dazg8xyLHGLrmpgq2nVNFUckhqdW3szVP6YhCpp/RAnpmVExA9JvrMynjwSLVrEj3AepHR6ew==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
|
||||
light-my-request@6.6.0:
|
||||
resolution: {integrity: sha512-CHYbu8RtboSIoVsHZ6Ye4cj4Aw/yg2oAFimlF7mNvfDV192LR7nDiKtSIfCuLT7KokPSTn/9kfVLm5OGN0A28A==}
|
||||
|
||||
@@ -4054,6 +4111,11 @@ packages:
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
nanoid@5.1.7:
|
||||
resolution: {integrity: sha512-ua3NDgISf6jdwezAheMOk4mbE1LXjm1DfMUDMuJf4AqxLFK3ccGpgWizwa5YV7Yz9EpXwEaWoRXSb/BnV0t5dQ==}
|
||||
engines: {node: ^18 || >=20}
|
||||
hasBin: true
|
||||
|
||||
napi-build-utils@2.0.0:
|
||||
resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==}
|
||||
|
||||
@@ -5415,6 +5477,9 @@ packages:
|
||||
zod@3.25.76:
|
||||
resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
|
||||
|
||||
zod@4.3.6:
|
||||
resolution: {integrity: sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==}
|
||||
|
||||
zustand@5.0.12:
|
||||
resolution: {integrity: sha512-i77ae3aZq4dhMlRhJVCYgMLKuSiZAaUPAct2AksxQ+gOtimhGMdXljRT21P5BNpeT4kXlLIckvkPM029OljD7g==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
@@ -7023,6 +7088,54 @@ snapshots:
|
||||
'@rollup/rollup-win32-x64-msvc@4.59.1':
|
||||
optional: true
|
||||
|
||||
'@scalar/core@0.4.5':
|
||||
dependencies:
|
||||
'@scalar/types': 0.7.5
|
||||
|
||||
'@scalar/fastify-api-reference@1.49.5':
|
||||
dependencies:
|
||||
'@scalar/core': 0.4.5
|
||||
'@scalar/openapi-parser': 0.25.6
|
||||
'@scalar/openapi-types': 0.6.1
|
||||
fastify-plugin: 4.5.1
|
||||
github-slugger: 2.0.0
|
||||
|
||||
'@scalar/helpers@0.4.2': {}
|
||||
|
||||
'@scalar/json-magic@0.12.4':
|
||||
dependencies:
|
||||
'@scalar/helpers': 0.4.2
|
||||
pathe: 2.0.3
|
||||
yaml: 2.8.3
|
||||
|
||||
'@scalar/openapi-parser@0.25.6':
|
||||
dependencies:
|
||||
'@scalar/helpers': 0.4.2
|
||||
'@scalar/json-magic': 0.12.4
|
||||
'@scalar/openapi-types': 0.6.1
|
||||
'@scalar/openapi-upgrader': 0.2.2
|
||||
ajv: 8.18.0
|
||||
ajv-draft-04: 1.0.0(ajv@8.18.0)
|
||||
ajv-formats: 3.0.1(ajv@8.18.0)
|
||||
jsonpointer: 5.0.1
|
||||
leven: 4.1.0
|
||||
yaml: 2.8.3
|
||||
|
||||
'@scalar/openapi-types@0.6.1':
|
||||
dependencies:
|
||||
zod: 4.3.6
|
||||
|
||||
'@scalar/openapi-upgrader@0.2.2':
|
||||
dependencies:
|
||||
'@scalar/openapi-types': 0.6.1
|
||||
|
||||
'@scalar/types@0.7.5':
|
||||
dependencies:
|
||||
'@scalar/helpers': 0.4.2
|
||||
nanoid: 5.1.7
|
||||
type-fest: 5.5.0
|
||||
zod: 4.3.6
|
||||
|
||||
'@sec-ant/readable-stream@0.4.1': {}
|
||||
|
||||
'@semantic-release/changelog@6.0.3(semantic-release@25.0.3(typescript@5.9.3))':
|
||||
@@ -7601,6 +7714,10 @@ snapshots:
|
||||
clean-stack: 5.3.0
|
||||
indent-string: 5.0.0
|
||||
|
||||
ajv-draft-04@1.0.0(ajv@8.18.0):
|
||||
optionalDependencies:
|
||||
ajv: 8.18.0
|
||||
|
||||
ajv-formats@3.0.1(ajv@8.18.0):
|
||||
optionalDependencies:
|
||||
ajv: 8.18.0
|
||||
@@ -8389,6 +8506,8 @@ snapshots:
|
||||
|
||||
fast-uri@3.1.0: {}
|
||||
|
||||
fastify-plugin@4.5.1: {}
|
||||
|
||||
fastify-plugin@5.1.0: {}
|
||||
|
||||
fastify@5.8.2:
|
||||
@@ -8555,6 +8674,8 @@ snapshots:
|
||||
|
||||
github-from-package@0.0.0: {}
|
||||
|
||||
github-slugger@2.0.0: {}
|
||||
|
||||
glob@10.5.0:
|
||||
dependencies:
|
||||
foreground-child: 3.3.1
|
||||
@@ -8865,12 +8986,16 @@ snapshots:
|
||||
optionalDependencies:
|
||||
graceful-fs: 4.2.11
|
||||
|
||||
jsonpointer@5.0.1: {}
|
||||
|
||||
jsqr@1.4.0: {}
|
||||
|
||||
lazystream@1.0.1:
|
||||
dependencies:
|
||||
readable-stream: 2.3.8
|
||||
|
||||
leven@4.1.0: {}
|
||||
|
||||
light-my-request@6.6.0:
|
||||
dependencies:
|
||||
cookie: 1.1.1
|
||||
@@ -9149,6 +9274,8 @@ snapshots:
|
||||
|
||||
nanoid@3.3.11: {}
|
||||
|
||||
nanoid@5.1.7: {}
|
||||
|
||||
napi-build-utils@2.0.0: {}
|
||||
|
||||
neo-async@2.6.2: {}
|
||||
@@ -10521,6 +10648,8 @@ snapshots:
|
||||
|
||||
zod@3.25.76: {}
|
||||
|
||||
zod@4.3.6: {}
|
||||
|
||||
zustand@5.0.12(@types/react@19.2.14)(react@19.2.4):
|
||||
optionalDependencies:
|
||||
'@types/react': 19.2.14
|
||||
|
||||
Reference in New Issue
Block a user