3import OpenAI from "npm:openai";
4
5async function getVals(username, type, limit) {
6 const res = await db.execute({
7 sql: `
21}
22
23async function checkHTTPPreviewUpgrade(code) {
24 const openai = new OpenAI();
25 const completion = await openai.chat.completions.create({
53 content: `const number = Math.random();
54
55 export default function(req: Request) {
56 return Response.json(number);
57 }`,
80
81/* This example will return the contents of a documentID passed in as the path as JSON. */
82export default async function(req: Request): Promise<Response> {
83 const docId = new URL(req.url).pathname.substring(1);
84
16 "name": "harlequinChickadee",
17 "probabilityUpgradeNeeded": true,
18 "reason": "The current code structure has several functions and program logic outside the main handler, including word selection, game state management, and SVG generation. These parts would not re-run with the new runtime, potentially affecting functionality. They need to be moved inside the handler to ensure consistent behavior across requests."
19 },
20 {
31 "name": "untitled_pinkRoundworm",
32 "probabilityUpgradeNeeded": true,
33 "reason": "The functions `addComment` and `getComments` as well as the initialization \nof the KEY variable perform actions that are intended to be run per request. These need to be moved \ninside the relevant HTTP handler to ensure the behavior remains consistent in the new runtime."
34 },
35 {
46 "name": "untitled_maroonSwallow",
47 "probabilityUpgradeNeeded": false,
48 "reason": "All the code, including the check for authentication,\n is inside the handler function. This means the behavior will stay \n the same with the new runtime."
49 },
50 {
51 "name": "wikiOG",
52 "probabilityUpgradeNeeded": true,
53 "reason": "The function `getWikipediaInfo` defined outside of the handler makes network requests and processes data for each request. In the new runtime, this function would only be executed once and cached. To ensure the same behavior in the new runtime, this function should be moved into the handler."
54 },
55 {
61 "name": "discordEventReceiver",
62 "probabilityUpgradeNeeded": false,
63 "reason": "All the relevant code for handling requests and logging input is inside the handler.\n No code needs to be moved for the new runtime to function correctly."
64 }
65]
1// import { Request, Response } from "./node_modules/express/index.js";
2export default async function(req: Request): Promise<Response> {
3 console.log("Request received:", req);
4
6import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
7
8// Utility functions
9const performSingleRequest = async (url) => {
10 const start = performance.now();
46};
47
48// Helper function to safely format numbers
49const safeToFixed = (number, decimalPlaces) => {
50 return number !== undefined && number !== null
286}
287
288export default async function(req: Request): Promise<Response> {
289 const stream = await renderToReadableStream(<App />, { bootstrapModules: [import.meta.url] });
290 return new Response(stream, { headers: { "content-type": "text/html" } });
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}
3import { twitterUser } from "https://esm.town/v/stevekrouse/twitterUser";
4
5export async function twitterSearch({
6 query,
7 start_time,
4import { html } from "https://esm.town/v/stevekrouse/html?v=5";
5
6export async function valReadme({ val, title }: {
7 val: { author: string; name: string };
8 title?: string;
15}
16
17export function serveReadme({ val, title }: {
18 val: { author: string; name: string };
19 title?: string;
5import { refs } from "https://esm.town/v/stevekrouse/refs?v=11";
6
7type CronFunction = (interval: Interval) => Promise<void>;
8
9export const cronEvalLogger = (cron: CronFunction): CronFunction => {
10 let interval: Interval;
11 const cronProxy = new Proxy(cron, {
6import { blob } from "https://esm.town/v/std/blob?v=10";
7
8function App() {
9 const [comments, setComments] = useState();
10 const [newComment, setNewComment] = useState("");
6await automerge.next.initializeBase64Wasm(automergeWasmBase64);
7
8export default async function(req: Request): Promise<Response> {
9 // from https://automerge.org/automerge/api-docs/js/
10 type DocType = { ideas: Array<automerge.Text> };