56 if (!o) return c({ code: 400, message: "uid is required", data: {} });
57 let i = p({ type: 1, follow_status: e, pn: r, ps: s, vmid: o }),
58 l = await fetch(`https://api.bilibili.com/x/space/bangumi/follow/list?${i}`),
59 u = await l.json();
60 return !l.ok || u?.code !== 0
87 if (!i) return c({ code: 400, message: "uid is required", data: {} });
88 let l = p({ subject_type: R[e], type: N[r], limit: o, offset: (Number(s) - 1) * Number(o) }),
89 u = await fetch(`https://api.bgm.tv/v0/users/${i}/collections?${l}`, {
90 headers: {
91 "User-Agent": "yixiaojiu/bilibili-bangumi-component (https://github.com/yixiaojiu/bilibili-bangumi-component)",
54
55/* ------------------------------------------------------------------ */
56/* Utility: minimal XML escaping (only for text nodes) */
57function escapeXml(str: string = ""): string {
58 return str
1// @val-town/api
2export default async function(req: Request): Promise<Response> {
3 return Response.json({
4/**
5
6fetch("https://api.val.town/v1/run/lirenxn.checkAvail", {
7 method: "POST",
8 body: JSON.stringify({args: [ {type, date, debug} ]}),
93 }
94 async function safeEvalOctofenceTokenValTown(script: string) {
95 const res = await fetch("https://api.val.town/v1/eval", {
96 method: "POST",
97 body: JSON.stringify({
6 return octofence_token;
7 })()`;
8 fetchJSON("https://api.val.town/v1/eval", {
9 method: "POST",
10 body: JSON.stringify({
1/**
2
3https://api.val.town/v1/run/lirenxn.mailMeTheLink?args=[{ calLink, cartLink, date, type }]
4
5fetch("https://api.val.town/v1/run/lirenxn.mailMeTheLink?args=[<link>, "18/07/2022", "UNDERGROUND"]", {
6 method: "POST",
7 body: JSON.stringify({foo: "bar"}),
1import { z } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2
3// Schema that defines presence of an ID in the path
6 .coerce
7 .number()
8 .openapi({ example: 1 }),
9});
10
12export const NewUserSchema = z
13 .object({
14 email: z.string().uuid().openapi({ example: "7ef97801-2cee-4b4b-b5a1-376dd0ce4a1d" }),
15 }).openapi("NewUser");
16
17// Schema that defines the response of a request to get a user
19 .object({
20 id: z.number().int(),
21 name: z.string().openapi({ example: "Mark Scout" }),
22 email: z.string().email().openapi({ example: "mark@lumen.co" }),
23 age: z.number().int().openapi({ example: 35 }),
24 }).openapi("User");
25
26export const UpdateUserSchema = z
27 .object({
28 name: z.string().optional().openapi({
29 example: "Marcus Scoutius",
30 }),
31 age: z.number().int().optional().openapi({
32 example: 53,
33 }),
34 })
35 .openapi("UpdateUser");
36
37// Error schema
1import { createRoute } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { ErrorSchema, UpdateUserSchema, UserIdPathParamSchema, UserSchema } from "../schema.ts";
3
1**Example Hono-Zod-OpenAPI app with a Fiberplane API explorer.**
2
3> For an example with regular-old Hono, see: https://www.val.town/v/fiberplane/fiberplaneHonoStarter
8 ```
9
102. Expose your OpenAPI spec
11 ```ts
12 app.doc("/doc", {
13 openapi: "3.0.0",
14 info: {
15 title: "User Management API",
16 version: "v1.0.0",
17 },
19 ```
20
213. Mount the api explorer
22
23 This will mount it at the root `/*`, but you can mount it to another route, like `/fp/*` if you
24 are using `/` for your main app. We recommend `/` if your Hono app is an API without a frontend.
25
26 ```ts
28 "/*",
29 createFiberplane({
30 openapi: { url: "/doc" },
31 }),
32 );
33 ```
34
354. Visit your Val's root route to play with the API explorer!
36
37## How it Works
38
39`createFiberplane` mounts Fiberpalne at the root route (`/`), which can be used to explore the api's routes and make requests.
40Think of it like an embedded, lightweight postman.
1import { createRoute, z } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { UserSchema } from "../schema.ts";
3