4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();
12import { joinURL } from "npm:ufo@1.3.2";
13
14const API_URL = "https://crates.io/api/v1/";
15
16const VersionSchema = transform(
17 object({
18 num: string(),
19 dl_path: string([toCustom(input => (new URL(input, API_URL)).href)]),
20 yanked: boolean(),
21 }),
27
28export async function getCrateInfo(crateName: string, version?: string) {
29 const createURL = joinURL(API_URL, `/crates/${crateName}`);
30 const crateInfo = parse(CrateInfoSchema, await ky.get(createURL).json());
31 const versions = crateInfo.versions.filter(it => !it.yanked);
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();
1/** @jsxImportSource https://esm.sh/hono@3.9.2/jsx **/
2import { swaggerUI } from "npm:@hono/swagger-ui";
3import { z } from "npm:@hono/zod-openapi";
4import { OpenAPIHono } from "npm:@hono/zod-openapi";
5import { createRoute } from "npm:@hono/zod-openapi";
6
7const ParamsSchema = z.object({
9 .string()
10 .min(3)
11 .openapi({
12 param: {
13 name: "id",
20const UserSchema = z
21 .object({
22 id: z.string().openapi({
23 example: "123",
24 }),
25 name: z.string().openapi({
26 example: "John Doe",
27 }),
28 age: z.number().openapi({
29 example: 42,
30 }),
31 })
32 .openapi("User");
33
34const route = createRoute({
50});
51
52const app = new OpenAPIHono();
53
54app.get("/", c =>
58 <ul>
59 <li>
60 <a href="/openapi.json">OpenAPI Spec</a>
61 </li>
62 <li>
64 </li>
65 <li>
66 Example API call:{" "}
67 <a href="/users/123">
68 <code>GET /users/123</code>
73 ));
74
75app.openapi(route, (c) => {
76 const { id } = c.req.valid("param");
77 return c.json({
82});
83
84app.doc("/openapi.json", {
85 openapi: "3.0.0",
86 info: {
87 version: "1.0.0",
88 title: "My API",
89 },
90});
91app.get("/swagger", swaggerUI({ url: "/openapi.json" }));
92
93export default app.fetch;
31 podnewsId = await getPodnewsId(podcastInfo.podcastId);
32 }
33 const apiURL = new URL(`/api/podcast-search/lookup-${podnewsId}`, BASE_URL);
34 const data = await ky.get(apiURL).json();
35 if (!Array.isArray(data)) return;
36 const feedUrl = data.at(0)?.feedUrl;
1Migrated from folder: A_Features/_23_12_04_Update_Vals_API/createVal
8 const getRandomRhyme = async (word: string) => {
9 const rhymeRes = await fetch(
10 `https://api.datamuse.com/words?rel_rhy=${word}`,
11 );
12 const rhymes = await rhymeRes.json();
20 };
21 const sendGroupmeMessage = async (bot_id: string, text: string) => {
22 const response = await fetch("https://api.groupme.com/v3/bots/post", {
23 method: "POST",
24 headers: {
1import { runValAPIAuth } from "https://esm.town/v/stevekrouse/runValAPIAuth";
2
3// grab the types off turso's client without importing it
6
7export function turso(keys, handle?) {
8 let val = "@std.tursoAPI";
9 let f = (method) => (...args) =>
10 runValAPIAuth({
11 val,
12 args: [method, args],
35## Architecture
36
37This @std.turso function is the client or SDK to @std.tursoAPI, which acts as a "proxy" to Turso. It handles authentication, creates databases, and forwards on your SQL queries. You can get lower latency (~200ms vs ~800ms), more storage, databases, CLI & API access by having your own Turso account.
5}
6
7const video_url = "https://api.bilibili.com/x/web-interface/dynamic/region?ps=6&rid=1";
8
9export async function get_random_video(cookie) {