Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add raw route #11

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"pnpm": {
"onlyBuiltDependencies": [
"workerd"
]
],
"overrides": {
"jsonpath-plus": "10.3.0"
}
}
}
13 changes: 8 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<HonoContext>();

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);

Expand Down
11 changes: 11 additions & 0 deletions src/middlewares/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 1 addition & 11 deletions src/routes/v1_categories.openapi.ts
Original file line number Diff line number Diff line change
@@ -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: "/",
Expand Down
7 changes: 7 additions & 0 deletions src/routes/v1_raw/index.ts
Original file line number Diff line number Diff line change
@@ -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<HonoContext>().basePath("/api/v1/raw/:version");

V1_RAW_ROUTER.use(versionMiddleware);
Comment on lines +5 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Router is defined but lacks route handlers

The V1_RAW_ROUTER is correctly set up with a base path and middleware, but there are no actual route handlers defined. This means the /api/v1/raw/:version endpoint won't handle any specific requests yet.

Consider adding route handlers to make this router functional, for example:


🏁 Script executed:

#!/bin/bash
# Check if there are any route handlers defined for this router in other files
find src -type f -name "*.ts" -exec grep -l "V1_RAW_ROUTER\.(get\|post\|put\|delete\|patch)" {} \;

Length of output: 103


I'm going to run an additional search to verify if any route handlers are defined for V1_RAW_ROUTER. Please run the script below and share its output so we can conclusively determine if the router remains unused for specific HTTP methods.


🏁 Script executed:

#!/bin/bash
echo "Searching for route handler definitions associated with V1_RAW_ROUTER:"
rg -n "V1_RAW_ROUTER\.(get|post|put|delete|patch)" src

Length of output: 207


Missing Route Handlers on V1_RAW_ROUTER

After verifying the codebase, it’s clear that while the router is correctly configured with a base path and middleware, there are no HTTP method handlers attached (e.g., GET, POST, PUT, DELETE, or PATCH). This means that the /api/v1/raw/:version endpoint isn’t currently set up to handle any requests.

  • File: src/routes/v1_raw/index.ts (lines 5–7)
  • Issue: No route handlers are defined on the V1_RAW_ROUTER
  • Suggestion: Add the necessary route handlers or, if the router is intended as a placeholder, document that the endpoints are pending implementation.