dynamicSleepmain.tsx1 match
1export default async function(req: Request): Promise<Response> {
2// parse the ?seconds=parameter from the url, default to 1 if missing
3const seconds = Number(new URL(req.url).searchParams.get("seconds")) || 1;
testBasicAuthmain.tsx1 match
2import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
34function handler(req: Request) {
5return new Response("You are authenticated!");
6}
audioManagermain.tsx8 matches
4344export class AudioManager {
45constructor(apiKey=null, uploadFunction = null, downloadFunction = null) {
46this.openai = new OpenAI(apiKey);
47this.uploadFunction = uploadFunction || this.blobUpload;
48}
4950// valtown blob upload function
51async blobUpload(buffer, key) {
52try {
111console.log(blob instanceof Blob); // Should be true
112console.log(typeof blob); // Should be true
113console.log(typeof blob.arrayBuffer); // Should be "function"
114return blob;
115}
164165async uploadAudio(blob, key) {
166if (!this.uploadFunction) {
167console.error("No upload function provided to upload audio");
168return null;
169}
170171// const buffer = await blob.arrayBuffer();
172const res = await this.uploadFunction(blob, key);
173if (res) {
174return res;
180181182// Function to fetch audio data and return as ArrayBuffer
183async getAudioBuffer(url) {
184const response = await fetch(url);
brownPelicanmain.tsx1 match
1export default async function (req: Request): Promise<Response> {
2return Response.json({ ok: true })
3}
CronScrapermain.tsx1 match
2import { email } from "https://esm.town/v/std/email";
34export async function main() {
5const areas: Area[] = [
6{
fetchCongressTradeReportsmain.tsx2 matches
91011export async function fetchCongressTradeReports(callback) {
12const res = await fetchJSON(
13"https://bff.capitoltrades.com/trades?sortBy=-pubDate"
15const trades = res.data;
1617function isToday(d) {
18const now = new Date();
19return (
1```
2export default async function main(req: Request): Promise<Response> {
3const html = `
4<!DOCTYPE html>
1```
2// This function returns an HTML response with a "Hello, World!" message styled using CSS
3// to have crazy colors and gradien
45export default async function main(req: Request) {
6const body = `
7<!DOCTYPE html>
1```
2export default async function main(req: Request): Promise<Response> {
3// Return a basic HTML response with "Hello, World!" message
4return new Response("<h1>Hello, World!</h1>", {
27the simplest way to achieve the goal, though you can add some inline comments to explain your
28reasoning (not for every line, but for major groups of lines). Don't use any environment variables
29unless strictly necessary, for example use APIs that don't require a key, prefer internal function
30imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
31functions where possible. Unless specified, don't add error handling,
32make sure that errors bubble up to the caller.
33There should be no comments like "more content here", it should be complete and directly runnable.
34The val should create a "export default async function main" which is the main function that gets
35executed on every HTTP request.
36`.replace("\n", " ");
3738// Your response should start with \`\`\`ts and end with \`\`\`.
39// The val should create a "export default async function main() {" which
40// is the main function that gets executed, without any arguments. Don't return a Response object,
41// just return a plain Javascript object, array, or string.
4270const writer = writable.getWriter();
71const textEncoder = new TextEncoder();
72function write(text: string) {
73writer.write(textEncoder.encode(text));
74}
113</div>
114<script>
115function openTab(tab) {
116const tabButtonCode = document.getElementById("tab-button-code");
117const tabButtonPreview = document.getElementById("tab-button-preview");
137(() => {
138const scrollingElement = document.getElementById("conversation-container");
139const callback = function (mutationsList, observer) {
140scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
141};
218document.getElementById("code-textarea").value = "";
219let fullStr = "";
220window.addToken = function(str) {
221fullStr += str;
222const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");