10}
11
12export async function fetchEnv() {
13 const { data: res, error } = await fetchValTown("/v1/eval", {
14 method: "POST",
28}
29
30export async function fetchValTown<T = any>(
31 path: string,
32 options?: RequestInit & {
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4
24 // });
25 // const message = data.choices[0].message;
26 // return message.function_call ? message.function_call : message.content;
27};
28
72});
73
74// You can build you own helper function
75function linkItem(title: string, url: string): Item {
76 return {
77 title,
1async function readStream(stream: ReadableStream) {
2 const reader = stream.getReader();
3 const decoder = new TextDecoder();
17}
18
19export default async function(req: Request): Promise<Response> {
20 let body = {};
21
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}
3import { html } from "https://esm.town/v/stevekrouse/html?v=5";
4
5export function article({
6 val,
7 title,
1import { trendingRepositories } from "https://esm.town/v/pomdtr/trendingRepositories";
2
3export async function sunbeamTrendingRepositories() {
4 const repositories = await trendingRepositories();
5 const items = repositories.map((repo) => ({
4import mime from "npm:mime";
5
6export function serveBlobs({
7 root,
8 mimes = {},
21</html>`;
22
23export function redirect(location: string): Response {
24 return new Response(null, {
25 headers: {
35};
36
37async function fetchUser(token: string): Promise<User> {
38 const resp = await fetch("https://api.val.town/v1/me", {
39 headers: {
49}
50
51async function isCurrentUser(userID: string) {
52 const currentUser = await fetchUser(Deno.env.get("valtown"));
53 return userID == currentUser.id;
54}
55
56function signout() {
57 const res = redirect("/");
58 cookie.setCookie(res.headers, {
67}
68
69export function auth(handler) {
70 const secretKey = Deno.env.get("AUTH_SECRET_KEY");
71 if (!secretKey) {
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",