diff --git a/package.json b/package.json index 6fc14c5..b113270 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,9 @@ "pnpm": { "onlyBuiltDependencies": [ "workerd" - ] + ], + "overrides": { + "jsonpath-plus": "10.3.0" + } } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a202e40..c61ffbf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,9 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +overrides: + jsonpath-plus: 10.3.0 + importers: .: @@ -2544,8 +2547,8 @@ packages: jsonfile@6.1.0: resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} - jsonpath-plus@10.2.0: - resolution: {integrity: sha512-T9V+8iNYKFL2n2rF+w02LBOT2JjDnTjioaNFrxRy0Bv1y/hNsqR/EBK7Ojy2ythRHwmz2cRIls+9JitQGZC/sw==} + jsonpath-plus@10.3.0: + resolution: {integrity: sha512-8TNmfeTCk2Le33A3vRRwtuworG/L5RrgMvdjhKZxvyShO+mBu2fP50OWUjRLNtvw344DdDarFh9buFAZs5ujeA==} engines: {node: '>=18.0.0'} hasBin: true @@ -4929,7 +4932,7 @@ snapshots: ajv-errors: 3.0.0(ajv@8.17.1) ajv-formats: 2.1.1(ajv@8.17.1) es-aggregate-error: 1.0.13 - jsonpath-plus: 10.2.0 + jsonpath-plus: 10.3.0 lodash: 4.17.21 lodash.topath: 4.5.2 minimatch: 3.1.2 @@ -6784,7 +6787,7 @@ snapshots: optionalDependencies: graceful-fs: 4.2.11 - jsonpath-plus@10.2.0: + jsonpath-plus@10.3.0: dependencies: '@jsep-plugin/assignment': 1.3.0(jsep@1.4.0) '@jsep-plugin/regex': 1.0.4(jsep@1.4.0) @@ -7236,7 +7239,7 @@ snapshots: astring: 1.9.0 jsep: 1.4.0 optionalDependencies: - jsonpath-plus: 10.2.0 + jsonpath-plus: 10.3.0 lodash.topath: 4.5.2 node-fetch@2.7.0: diff --git a/src/index.ts b/src/index.ts index f3866b6..d77f163 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,12 +7,14 @@ import { buildOpenApiConfig } from "./openapi"; import { GATEWAY_GITHUB_ROUTER } from "./routes/gateway_github"; import { RANDOM_EMOJI_ROUTER } from "./routes/random-emoji"; import { V1_CATEGORIES_ROUTER } from "./routes/v1_categories"; +import { V1_RAW_ROUTER } from "./routes/v1_raw"; import { V1_VERSIONS_ROUTER } from "./routes/v1_versions"; const app = new OpenAPIHono(); app.route("/", V1_VERSIONS_ROUTER); app.route("/", V1_CATEGORIES_ROUTER); +app.route("/", V1_RAW_ROUTER); app.route("/", GATEWAY_GITHUB_ROUTER); app.route("/", RANDOM_EMOJI_ROUTER); diff --git a/src/middlewares/version.ts b/src/middlewares/version.ts index b4796fd..2d15b4c 100644 --- a/src/middlewares/version.ts +++ b/src/middlewares/version.ts @@ -3,6 +3,17 @@ import { createError, getAvailableVersions } from "../utils"; const DEFAULT_FALLBACK_VERSION = "15.1"; +export const VERSION_PATH_PARAMETER = { + in: "path" as const, + name: "version", + description: "The version of the emoji data to use", + required: true, + example: "latest", + schema: { + type: "string" as const, + }, +}; + export const versionMiddleware = createMiddleware(async (c, next) => { const version = c.req.param("version"); const fullPath = c.req.path; diff --git a/src/routes/v1_categories.openapi.ts b/src/routes/v1_categories.openapi.ts index b9fe3b1..5e21c62 100644 --- a/src/routes/v1_categories.openapi.ts +++ b/src/routes/v1_categories.openapi.ts @@ -1,17 +1,7 @@ import { createRoute, z } from "@hono/zod-openapi"; +import { VERSION_PATH_PARAMETER } from "../middlewares/version"; import { ApiErrorSchema, EmojiCategorySchema } from "../schemas"; -const VERSION_PATH_PARAMETER = { - in: "path" as const, - name: "version", - description: "The emoji version to retrieve categories for", - required: true, - example: "latest", - schema: { - type: "string" as const, - }, -}; - export const ALL_CATEGORIES_ROUTE = createRoute({ method: "get", path: "/", diff --git a/src/routes/v1_raw/index.ts b/src/routes/v1_raw/index.ts new file mode 100644 index 0000000..11a9afe --- /dev/null +++ b/src/routes/v1_raw/index.ts @@ -0,0 +1,7 @@ +import type { HonoContext } from "../../types"; +import { OpenAPIHono } from "@hono/zod-openapi"; +import { versionMiddleware } from "../../middlewares/version"; + +export const V1_RAW_ROUTER = new OpenAPIHono().basePath("/api/v1/raw/:version"); + +V1_RAW_ROUTER.use(versionMiddleware);