Skip to content

Commit ae97472

Browse files
committed
feat: expose new versions supported endpoint
1 parent 7cc2f83 commit ae97472

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ApiError, HonoEnv } from "./types";
22
import { OpenAPIHono } from "@hono/zod-openapi";
33
import { getAllEmojiVersions } from "@mojis/internal-utils/versions";
4-
import { apiReference } from "@scalar/hono-api-reference";
4+
import { Scalar } from "@scalar/hono-api-reference";
55
import { env } from "hono/adapter";
66
import { HTTPException } from "hono/http-exception";
77
import { buildOpenApiConfig } from "./openapi";
@@ -18,10 +18,9 @@ app.route("/", V1_CATEGORIES_ROUTER);
1818
app.route("/", GATEWAY_GITHUB_ROUTER);
1919
app.route("/", DATA_SCHEMAS_ROUTER);
2020
app.route("/", RANDOM_EMOJI_ROUTER);
21-
2221
app.get(
2322
"/scalar",
24-
apiReference({
23+
Scalar({
2524
url: "/openapi.json",
2625
layout: "classic",
2726
customCss: /* css */`

src/routes/v1_versions.openapi.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,28 @@ export const DRAFT_EMOJI_VERSIONS_ROUTE = createRoute({
100100
},
101101
},
102102
});
103+
104+
export const SUPPORTED_VERSIONS_ROUTE = createRoute({
105+
method: "get",
106+
path: "/supported",
107+
tags: ["Versions"],
108+
description: "Retrieve a list of emoji versions that is supported by @mojis",
109+
responses: {
110+
200: {
111+
content: {
112+
"application/json": {
113+
schema: z.array(z.string()).openapi("SupportedVersions"),
114+
},
115+
},
116+
description: "Retrieve a list of emoji versions that is supported by @mojis",
117+
},
118+
500: {
119+
content: {
120+
"application/json": {
121+
schema: ApiErrorSchema,
122+
},
123+
},
124+
description: "Internal Server Error",
125+
},
126+
},
127+
});

src/routes/v1_versions.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { HonoEnv } from "../types";
22
import { OpenAPIHono } from "@hono/zod-openapi";
3+
import { OFFICIAL_SUPPORTED_VERSIONS } from "@mojis/internal-utils/constants";
34
import { cache } from "../middlewares/cache";
45
import { createError, getAvailableVersions } from "../utils";
5-
import { ALL_EMOJI_VERSIONS_ROUTE, DRAFT_EMOJI_VERSIONS_ROUTE, LATEST_EMOJI_VERSIONS_ROUTE } from "./v1_versions.openapi";
6+
import { ALL_EMOJI_VERSIONS_ROUTE, DRAFT_EMOJI_VERSIONS_ROUTE, LATEST_EMOJI_VERSIONS_ROUTE, SUPPORTED_VERSIONS_ROUTE } from "./v1_versions.openapi";
67

78
export const V1_VERSIONS_ROUTER = new OpenAPIHono<HonoEnv>().basePath("/api/v1/versions");
89

@@ -60,3 +61,7 @@ V1_VERSIONS_ROUTER.openapi(DRAFT_EMOJI_VERSIONS_ROUTE, async (c) => {
6061
return createError(c, 500, "failed to fetch emoji data");
6162
}
6263
});
64+
65+
V1_VERSIONS_ROUTER.openapi(SUPPORTED_VERSIONS_ROUTE, (c) => {
66+
return c.json(OFFICIAL_SUPPORTED_VERSIONS, 200);
67+
});

0 commit comments

Comments
 (0)