Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=api&page=154&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=api

Returns an array of strings in format "username" or "username/projectName"

Found 11844 results for "api"(1138ms)

1import { createRoute, z } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { UserSchema } from "../schema.ts";
3

fiberplaneHonoZodStarterindex.ts17 matches

@crisscrossed•Updated 2 weeks ago
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";
5
6import { 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";
15
16const app = new OpenAPIHono<AppType>();
17
18app.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});
31
32app.openapi(listUsersRoute, (c) => {
33 const { name } = c.req.valid("query");
34
38});
39
40app.openapi(createUserRoute, (c) => {
41 const { name, email, age } = c.req.valid("json");
42
46});
47
48app.openapi(updateUserRoute, (c) => {
49 const { id } = c.req.valid("param");
50 const { name, age } = c.req.valid("json");
59});
60
61app.openapi(deleteUserRoute, (c) => {
62 const { id } = c.req.valid("param");
63
73});
74
75// Mount an API with bearer auth
76app.route("/protected", superProtectedApi);
77
78// Create OpenAPI documentation
79app.doc("/openapi.json", {
80 openapi: "3.0.0",
81 info: {
82 title: "User Management API",
83 version: "v1.0.0",
84 },
86
87// Swagger UI
88app.get("/docs", swaggerUI({ url: "/openapi.json" }));
89
90// Mount the Fiberplane UI at the root to be able to test api endpoints
91app.use(
92 "/*",
93 createFiberplane({
94 openapi: { url: "/openapi.json" },
95 }),
96);

fiberplaneHonoZodStarterhelpers.ts1 match

@crisscrossed•Updated 2 weeks ago
1import { z } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { UserSchema } from "./schema.ts";
3

fiberplaneHonoZodStarterget-user.ts1 match

@crisscrossed•Updated 2 weeks ago
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

@crisscrossed•Updated 2 weeks ago
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";
7
8export const superProtectedApi = new OpenAPIHono<AppType>();
9
10// Define a mock route that is protected with bearer auth
34
35// Mock middleware that just returns 401 if there's no authorization header for the request
36superProtectedApi.use(async (c, next) => {
37 if (!c.req.header("authorization")) {
38 return c.json({ error: "Unauthorized" }, 401);
41});
42
43superProtectedApi.openapi(superSecretSecretsRoute, c => {
44 return c.json({ secrets: ["cold harbor", "other secret idk"] }, 200);
45});
46
47superProtectedApi.openAPIRegistry.registerComponent("securitySchemes", "Bearer", {
48 type: "http",
49 scheme: "bearer",

topbottomdemomain.tsx1 match

@dcm31•Updated 2 weeks ago
17 useEffect(() => {
18 if (typeof navigator === 'undefined' || !navigator.mediaDevices) {
19 setError("MediaDevices API not available in this environment");
20 return;
21 }

EmailAttachmentLogindex.ts3 matches

@wolf•Updated 2 weeks ago
7const app = new Hono();
8
9// API routes
10app.get("/api/attachments", async (c) => {
11 const attachments = await getAllAttachments();
12 return c.json(attachments);
13});
14
15app.get("/api/attachments/:id", async (c) => {
16 const id = c.req.param("id");
17 const result = await getAttachment(id);

EmailAttachmentLogApp.tsx3 matches

@wolf•Updated 2 weeks ago
37 <div className="flex gap-2">
38 <a
39 href={`/api/attachments/${attachment.id}`}
40 target="_blank"
41 className="px-3 py-1 bg-gray-100 text-sm border border-gray-200"
44 </a>
45 <a
46 href={`/api/attachments/${attachment.id}`}
47 download={attachment.filename}
48 className="px-3 py-1 bg-gray-100 text-sm border border-gray-200"
68
69 // Fetch attachments
70 fetch('/api/attachments')
71 .then(response => {
72 if (!response.ok) {

simple-scrabble-api1 file match

@bry•Updated 10 hours ago

social_data_api_project3 file matches

@tsuchi_ya•Updated 18 hours ago
apiv1
papimark21