12]
13
14function shuffleArray(arr) {
15 return arr.toSorted(() => {
16 return Math.random() > 0.5 ? 1 : -1
26];
27
28function reducer(state) {
29 return state + 1;
30}
31
32function App() {
33 let [count, dispatch] = useReducer(reducer, 0);
34
43}
44
45export function renderApp() {
46 let root = createRoot(document.getElementById("root")!);
47
2
3/**
4 * You can supply these options as a second argument to the `proxy` function.
5 * These options are used to configure the frontend.
6 */
135
136export const proxy = (url: string, options?: FrontendOptions) => {
137 return async function(req: Request): Promise<Response> {
138 if (req.method === "GET") {
139 return renderFrontend(url, options);
4const TIMEOUT = 30000; // 30 seconds timeout
5
6export default async function server(request: Request): Promise<Response> {
7 // Array of URLs to scrape
8 const urls = [
128
129export const service = (boardUrl: string, options?: ServiceOptions) => {
130 return async function(req: Request): Promise<Response> {
131 const url = new URL(req.url);
132 const path = url.pathname;
18
19type User = { id: string; username: string; tier: string };
20export default async function(req: Request): Promise<Response> {
21 // Ensure only allowed pathnames are used
22 const { pathname, search } = new URL(req.url);
82
83// Free users are limited to gpt-4o-mini. Limit pro users to 10 expensive model requests.
84async function limitFreeModel(req: Request, user: User) {
85 const input = await req.json();
86 let model = "gpt-4o-mini";
128
129export const service = (boardUrl: string, options?: ServiceOptions) => {
130 return async function(req: Request): Promise<Response> {
131 const url = new URL(req.url);
132 const path = url.pathname;
2
3/**
4 * You can supply these options as a second argument to the `proxy` function.
5 * These options are used to configure the frontend.
6 */
135
136export const proxy = (url: string, options?: FrontendOptions) => {
137 return async function(req: Request): Promise<Response> {
138 if (req.method === "GET") {
139 return renderFrontend(url, options);
13must contain your board server API key.
14
15To use, create an HTTP val, then import the `proxy` function from this script and call it like this:
16
17```ts
13must contain your board server API key.
14
15To use, create an HTTP val, then import the `proxy` function from this script and call it like this:
16
17```ts
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [SplineComponent, setSplineComponent] = useState(null);
7 const [error, setError] = useState(null);
50}
51
52function client() {
53 createRoot(document.getElementById("root")).render(<App />);
54}
56if (typeof document !== "undefined") { client(); }
57
58async function server(request: Request): Promise<Response> {
59 return new Response(
60 `
A helper function to build a file's email
Simple functional CSS library for Val Town
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": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.