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' \
1import { API_URL } from "https://esm.town/v/std/API_URL";
2
3/**
7 * @param {string | URL | Request} input - The resource to fetch.
8 * @param {RequestInit} [requestInit] - Optional configuration data (HTTP
9 * method, headers, etc) ([Docs ↗](https://deno.land/api@v1.42.1?s=RequestInit))
10 */
11export async function fetch(input: string | URL | Request, requestInit?: RequestInit) {
12 const origReq = new Request(input, requestInit);
13 const url = new URL("/v1/fetch", API_URL);
14 url.searchParams.set("url", origReq.url);
15 const req = new Request(url, origReq);
1import { API_URL } from "https://esm.town/v/std/API_URL";
2
3/**
7 * @param {string | URL | Request} input - The resource to fetch.
8 * @param {RequestInit} [requestInit] - Optional configuration data (HTTP
9 * method, headers, etc) ([Docs ↗](https://deno.land/api@v1.42.1?s=RequestInit))
10 */
11export async function fetch(input: string | URL | Request, requestInit?: RequestInit) {
12 const origReq = new Request(input, requestInit);
13 const url = new URL("/v1/fetch", API_URL);
14 url.searchParams.set("url", origReq.url);
15 const req = new Request(url, origReq);
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { LibsqlError, type TransactionMode } from "npm:@libsql/client";
3import { z } from "npm:zod";
35
36async function execute(statement: InStatement): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
49
50async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
51 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
52 method: "POST",
53 headers: {
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { rawFetch } from "https://esm.town/v/std/rawFetch";
3
8 * @param {string | URL} input - The URL to fetch
9 * @param {RequestInit} [requestInit] - Optional configuration data (HTTP
10 * method, headers, etc) ([Docs ↗](https://deno.land/api@v1.42.1?s=RequestInit))
11 */
12export async function fetch(input: string | URL, requestInit?: RequestInit) {
14 url: input.toString(),
15 });
16 return rawFetch(`${API_URL}/v1/fetch?${query}`, {
17 ...requestInit,
18 headers: {