1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { ValTownBlobError } from "https://esm.town/v/std/ValTownBlobError";
3import { ValTownBlobNotFoundError } from "https://esm.town/v/std/ValTownBlobNotFoundError";
82async function list(prefix?: string): Promise<{ key: string; size: number; lastModified: string }[]> {
83 let querystring = prefix ? `?prefix=${encodeURIComponent(prefix)}` : "";
84 const res = await fetch(`${API_URL}/v1/blob${querystring}`, {
85 headers: {
86 Authorization: `Bearer ${Deno.env.get("valtown")}`,
95
96async function delete_(key: string) {
97 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
98 method: "DELETE",
99 headers: {
108
109async function get(key: string) {
110 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
111 headers: {
112 Authorization: `Bearer ${Deno.env.get("valtown")}`,
127 value = value.body;
128 }
129 const res = await fetch(`${API_URL}/v1/blob/${encodeURIComponent(key)}`, {
130 method: "POST",
131 headers: {
2
3const craftgate = new Craftgate.Client({
4 apiKey: "sandbox-YEhueLgomBjqsnvBlWVVuFsVhlvJlMHE",
5 secretKey: "sandbox-tBdcdKVGmGupzfaWcULcwDLMoglZZvTz",
6 baseUrl: "https://sandbox-api.craftgate.io",
7});
8
1# Set Blob Storage via fetch Response body
2
3Inspired by [Wes Bos's tweet](https://twitter.com/wesbos/status/1775558324454392064?t=Pnx8jDyfF7wVbZJp0QnNJw&s=19) about Bun's elegant Filesystem API.
4
5Migrated from folder: Archive/blobSetResponseBodyExample
60
61 let body: string | ReadableStream<Uint8Array> | null = null;
62 // https://api.fireworks.ai/inference/v1/models
63 if (pathname == COMPLETION) {
64 const params = await req.clone().json();
74 body = req.body;
75 }
76 url.host = "api.fireworks.ai";
77 url.port = "443";
78 url.protocol = "https";
92 const response = await fetch(url.toString(), init);
93 const responseHeaders = new Headers(response.headers);
94 // Special handling for /api/v1/models
95 if (pathname == MODELS) {
96 // Clone the response to read it without consuming the original stream
1import vtApi from "https://esm.town/v/neverstew/vtApi";
2
3const res = await vtApi.GET("/v1/search/vals", {
4 params: { query: { query: "api" } },
5});
6const vals = res.data.data;
1Migrated from folder: vtapi/vtApiExample
1import { updateValByName } from "https://esm.town/v/nbbaier/updateValByName?v=14";
2import openapiTS from "npm:openapi-typescript";
3
4export default async () => {
5 const output = await openapiTS("https://www.val.town/docs/openapi.yaml");
6 await updateValByName({
7 token: Deno.env.get("valtown"),
8 name: "vtApiTypes",
9 code: output,
10 });
1Migrated from folder: vtapi/vtApiTypes
1Migrated from folder: vtapi/updateVtApiTypes
1```
2curl 'https://taras-free_open_router.web.val.run/api/v1/chat/completions' \
3 -H 'accept: application/json' \
4 -H 'authorization: Bearer THIS_IS_OVERRIDEN_ON_SERVER' \