1export async function slackPost(token, channel, text) {
2 const resp = await fetch(
3 `https://slack.com/api/chat.postMessage`,
4 {
5 method: "POST",
37
38## How it works
39The sketch function returns an http handler that sets up a basic page with p5.js added. It then imports your module from the browser and wires up all the exports so p5.js can see them. All the code in your val will run in the browser (except for the default `sketch` export) so you can't call any Deno functions, environment variables, or other server side apis.
40
41
74 }
75 case "projects": {
76 const resp = await fetchDeployAPI("/projects");
77 if (resp.status != 200) {
78 throw new Error("Failed to fetch projects");
126 }
127 case "playground": {
128 const resp = await fetchDeployAPI(`/projects/${payload.params.project}`);
129 if (resp.status != 200) {
130 throw new Error("Failed to fetch project");
164 const project = payload.params.project;
165
166 const resp = await fetchDeployAPI(`/projects/${project}/deployments`);
167 if (resp.status != 200) {
168 throw new Error("Failed to fetch deployments");
212}
213
214function fetchDeployAPI(endpoint: string, init?: RequestInit) {
215 return fetch(`https://dash.deno.com/api${endpoint}`, {
216 ...init,
217 headers: {
35
36 // we check that we are not exposing private vals
37 const resp = await fetch(`https://api.val.town/v1/alias/${author}/${name}`, {
38 headers: {
39 authorization: `Bearer ${Deno.env.get("valtown")}`,
1export function myApi(name) {
2 return "hi " + name;
3}
1export async function track(domain: string, req: Request) {
2 await fetch("https://plausible.io/api/event", {
3 method: "POST",
4 headers: {
1Migrated from folder: GPTs/ApiFramework/gptApiSchemaBuilder
1Allows for automatic generation of Hono API compatible with GPTs. Endpoints' inputs and outputs need to be specified via types from which the Open API spec is generated automatically and available via `/gpt/schema` endpoint.
2
3> ⚠️ Breaking changes introduced in v23 & 24:
8
9```ts
10import { GptApi } from "https://esm.town/v/xkonti/gptApiFramework";
11import { z } from "npm:zod";
12
22
23/**
24 * INITIALIZE API
25 */
26
27const api = new GptApi({
28 url: "https://xkonti-planoverseerai.web.val.run",
29 title: "Overseer AI API",
30 description: "The API for interacting with the Overseer AI",
31 version: "1.0.0",
32 policyGetter: async () => {
40 */
41
42api.nothingToJson({
43 verb: "POST",
44 path: "/newproblem",
55});
56
57export default api.serve();
58```
59
60Migrated from folder: GPTs/ApiFramework/gptApiFramework
2
3export const handler = async () => {
4 const hashrateResp = await fetch("https://mempool.space/api/v1/mining/hashrate/3y");
5 const { difficulty } = await hashrateResp.json();
6
2
3export default async function(req: Request): Promise<Response> {
4 const blockFeesResp = await fetch("https://mempool.space/api/v1/mining/blocks/fees/3y");
5 const blockFees = await blockFeesResp.json();
6