1import { createRoute, z } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { UserSchema } from "../schema.ts";
3
fiberplaneHonoZodStarterindex.ts17 matches
1import { createFiberplane } from "https://esm.sh/@fiberplane/hono@0.4.4";
2import { swaggerUI } from "https://esm.sh/@hono/swagger-ui@0.2.0";
3import { OpenAPIHono } from "https://esm.sh/@hono/zod-openapi@0.18.4";
4import { HTTPException } from "https://esm.sh/hono@4.7.0/http-exception";
56import { createUser, deleteUser, filterUsersByName, findUserById, updateUser } from "./helpers.ts";
7import { superProtectedApi } from "./protected/api.ts";
8import { createUserRoute } from "./routes/create-user.ts";
9import { deleteUserRoute } from "./routes/delete-user.ts";
14import type { AppType } from "./types.ts";
1516const app = new OpenAPIHono<AppType>();
1718app.openapi(getUserRoute, (c) => {
19// This id is coerced to a number by the Zod schema for path parameters
20// See: `UserIdPathParamSchema` in `schema.ts`
30});
3132app.openapi(listUsersRoute, (c) => {
33const { name } = c.req.valid("query");
3438});
3940app.openapi(createUserRoute, (c) => {
41const { name, email, age } = c.req.valid("json");
4246});
4748app.openapi(updateUserRoute, (c) => {
49const { id } = c.req.valid("param");
50const { name, age } = c.req.valid("json");
59});
6061app.openapi(deleteUserRoute, (c) => {
62const { id } = c.req.valid("param");
6373});
7475// Mount an API with bearer auth
76app.route("/protected", superProtectedApi);
7778// Create OpenAPI documentation
79app.doc("/openapi.json", {
80openapi: "3.0.0",
81info: {
82title: "User Management API",
83version: "v1.0.0",
84},
8687// Swagger UI
88app.get("/docs", swaggerUI({ url: "/openapi.json" }));
8990// Mount the Fiberplane UI at the root to be able to test api endpoints
91app.use(
92"/*",
93createFiberplane({
94openapi: { url: "/openapi.json" },
95}),
96);
1import { z } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { UserSchema } from "./schema.ts";
3
1import { createRoute } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { ErrorSchema, UserIdPathParamSchema, UserSchema } from "../schema.ts";
3
1import { createRoute } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { ErrorSchema, UserIdPathParamSchema } from "../schema.ts";
3
1import { createRoute } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { ErrorSchema, NewUserSchema, UserIdPathParamSchema, UserSchema } from "../schema.ts";
3
fiberplaneHonoZodStarterapi.ts7 matches
1import { OpenAPIHono } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { createRoute } from "https://esm.sh/@hono/zod-openapi@0.18.4";
3import { z } from "https://esm.sh/@hono/zod-openapi@0.18.4";
4import { HTTPException } from "https://esm.sh/hono@4.7.0/http-exception";
5import { ErrorSchema } from "../schema.ts";
6import type { AppType } from "../types.ts";
78export const superProtectedApi = new OpenAPIHono<AppType>();
910// Define a mock route that is protected with bearer auth
3435// Mock middleware that just returns 401 if there's no authorization header for the request
36superProtectedApi.use(async (c, next) => {
37if (!c.req.header("authorization")) {
38return c.json({ error: "Unauthorized" }, 401);
41});
4243superProtectedApi.openapi(superSecretSecretsRoute, c => {
44return c.json({ secrets: ["cold harbor", "other secret idk"] }, 200);
45});
4647superProtectedApi.openAPIRegistry.registerComponent("securitySchemes", "Bearer", {
48type: "http",
49scheme: "bearer",
topbottomdemomain.tsx1 match
17useEffect(() => {
18if (typeof navigator === 'undefined' || !navigator.mediaDevices) {
19setError("MediaDevices API not available in this environment");
20return;
21}
EmailAttachmentLogindex.ts3 matches
7const app = new Hono();
89// API routes
10app.get("/api/attachments", async (c) => {
11const attachments = await getAllAttachments();
12return c.json(attachments);
13});
1415app.get("/api/attachments/:id", async (c) => {
16const id = c.req.param("id");
17const result = await getAttachment(id);
EmailAttachmentLogApp.tsx3 matches
37<div className="flex gap-2">
38<a
39href={`/api/attachments/${attachment.id}`}
40target="_blank"
41className="px-3 py-1 bg-gray-100 text-sm border border-gray-200"
44</a>
45<a
46href={`/api/attachments/${attachment.id}`}
47download={attachment.filename}
48className="px-3 py-1 bg-gray-100 text-sm border border-gray-200"
6869// Fetch attachments
70fetch('/api/attachments')
71.then(response => {
72if (!response.ok) {