import { randomInt } from "node:crypto";
import { type Context, Hono } from "hono";
import { logger } from "hono/logger";
import { swaggerUI } from "@hono/swagger-ui";
const rootHandler = (ctx: Context): Response => {
return ctx.json({
r256: randomInt(0, 256),
});
};
const subHandler = (ctx: Context): Response => {
return ctx.json({
sub: ctx.req.param("sub"),
r256: randomInt(0, 256),
});
};
const app = new Hono();
app.use(logger());
app.get("/ui", swaggerUI({ url: "/doc" }));
app.get("/", rootHandler);
app.get("/:sub", subHandler);
Deno.serve({ port: 3000 }, app.fetch);
import { randomInt } from "node:crypto";
import { type Context, Hono } from "hono";
import { logger } from "hono/logger";
import { swaggerUI } from "@hono/swagger-ui";
const rootHandler = (ctx: Context): Response => {
return ctx.json({
r256: randomInt(0, 256),
});
};
const subHandler = (ctx: Context): Response => {
return ctx.json({
sub: ctx.req.param("sub"),
r256: randomInt(0, 256),
});
};
const app = new Hono();
app.use(logger());
app.get("/ui", swaggerUI({ url: "/doc" }));
app.get("/", rootHandler);
app.get("/:sub", subHandler);
Deno.serve({ port: 3000 }, app.fetch);