openapi_schemamain.tsx12 matches
1/**
2* This file was auto-generated by openapi-typescript.
3* Do not make direct changes to the file.
4*/
428* Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.
429*
430* Vals generated via this API will *not* appear in the authenticated user's workspace.
431*/
432get: {
464* Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.
465*
466* Vals generated via this API will *not* appear in the authenticated user's workspace.
467*/
468post: {
524"/v1/run/{username}.{val_name}": {
525/**
526* Run a val as an API
527* @deprecated
528* @description This endpoint runs the specified user's val and returns the output.
556};
557/**
558* Run a val as an API
559* @deprecated
560*/
593"/": {
594/**
595* Run a val as an API (as an Express handler)
596* @description Runs `@{username}.{val_name}` as an Express handler.
597*
598* `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).
599*
600* Unlike the other two APIs, the Express API is specified via subdomain and runs at `https://{username}-{val_name}.express.val.run`.
601*
602* ### Unauthenticated
603* Unauthenticated use will only be able to call public vals as Express handlers.
604*
605* The val will be executed with `{username}`'s permissions ("API Mode"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.
606*
607* ### Authenticated
631};
632/**
633* Run a val as an API (as an Express handler)
634* @description Runs `@{username}.{val_name}` as an Express handler.
635*
636* `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).
637*
638* ### Unauthenticated
639* Unauthenticated use will only be able to call public vals as Express handlers.
640*
641* The val will be executed with `{username}`'s permissions ("API Mode"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.
642*
643* ### Authenticated
generate_openapi_schemamain.tsx3 matches
1import createClient from "https://esm.town/v/pomdtr/val_town_client";
2import openapiTS from "npm:openapi-typescript";
34const client = createClient({
6});
78const code = await openapiTS(new URL("https://pomdtr-val_town_openapi.web.val.run"));
9const { data, error, response } = await client.PUT("/v1/vals", {
10body: {
11name: "openapi_schema",
12code: code,
13},
78});
7980app.get("/api/bookmarks", async (c) => {
81var baseUrl = c.req.url;
82var page = parseInt(c.req.query("page") || "0");
2425const env = JSON.parse(res);
26delete env["VALTOWN_API_URL"];
27return env;
28}
34},
35): Promise<{ data: T; error?: Error }> {
36const apiURL = Deno.env.get("API_URL") || "https://api.val.town";
37const headers = {
38...options?.headers,
41if (options?.paginate) {
42const data = [];
43let url = new URL(`${apiURL}${path}`);
44url.searchParams.set("limit", "100");
4568}
6970const resp = await fetch(`${apiURL}${path}`, {
71...options,
72headers,
5options = {},
6) => {
7// Initialize OpenAI API stub
8const { Configuration, OpenAIApi } = await import(
9"https://esm.sh/openai@3.3.0"
10);
11console.log(process.env);
12// const configuration = new Configuration({
13// apiKey: process.env.OPENAI,
14// });
15// const openai = new OpenAIApi(configuration);
16// // Request chat completion
17// const messages = typeof prompt === "string"
tree_examplemain.tsx3 matches
4*/
56import { api } from "https://esm.town/v/pomdtr/api";
7import type { Tree } from "https://esm.town/v/pomdtr/tree_types";
8import { Hono } from "npm:hono";
49});
5051// this endpoint is used to dynamically fetch a list of tags from the api
52app.get("/tags/:tag", async (c) => {
53let { tag } = c.req.param();
55tag = "#" + tag;
56}
57const { data: vals } = await api(
58`/v1/search/vals?query=${encodeURIComponent(tag)}`
59);
1import { api } from "https://esm.town/v/pomdtr/api";
2import { gfm } from "https://esm.town/v/pomdtr/gfm";
3import { html } from "https://esm.town/v/stevekrouse/html?v=5";
26title = `@${val.author}/${val.name}`;
27}
28const { code, readme } = await api(`/v1/alias/${val.author}/${val.name}`);
2930return html(await gfm(readme, { title, favicon: "📝" }));
auth_middlewaremain.tsx2 matches
12<article>
13<form method="post">
14<label for="token"><a href="https://www.val.town/settings/api">API Token</a></label>
15<input id="token" name="token" type="password" />
16<button type="submit">Submit</button>
3637async function fetchUser(token: string): Promise<User> {
38const resp = await fetch("https://api.val.town/v1/me", {
39headers: {
40Authorization: `Bearer ${token}`,
78});
7980app.get("/api/bookmarks", async (c) => {
81var baseUrl = c.req.url;
82var page = parseInt(c.req.query("page") || "0");
1import { api } from "https://esm.town/v/pomdtr/api";
2import { email } from "https://esm.town/v/std/email?v=12";
3import { OpenAI } from "https://esm.town/v/std/OpenAI";
45async function getValByAlias({ author, name }: { author: string; name: string }) {
6const { id, code, readme } = await api(`/v1/alias/${author}/${name}`, {
7authenticated: true,
8});
13async function updateValCode({ id, code }: { id: string; code: string }) {
14console.log({ id, code });
15await api(`/v1/vals/${id}/versions`, {
16authenticated: true,
17method: "POST",