1import type { Plugin, Post } from "./types";
23export async function parse(post: Post, plugins: Plugin[]) {
4return await plugins.reduce(async (acc: Promise<Post>, plugin: Plugin) => {
5const post = await acc;
10const THROTTLE = 1000
1112export default async function(req: Request): Promise<Response> {
13if (working) {
14return Response.json({
1export default async function(request: Request) {
2const { prompt } = await request.json();
3
1export default async function (request: Request) {
2const { prompt } = await request.json();
3
URLReceiverURLReceiverTest10 matches
22inputs: Record<string, unknown>;
23expectedResult: unknown;
24function: Function;
25}
262829// Create test cases by combining URLs with modifications
30function createURLTests(): TestCase[] {
31const tests: TestCase[] = [];
3236inputs: { url: baseURL },
37expectedResult: { isValid: true },
38function: urlReceiver.receiveURL.bind(urlReceiver),
39});
4043inputs: { url: TEST_MODIFICATIONS.withHTTP(baseURL) },
44expectedResult: { isValid: true },
45function: urlReceiver.receiveURL.bind(urlReceiver),
46});
4753error: "URL must use HTTP or HTTPS protocol",
54},
55function: urlReceiver.receiveURL.bind(urlReceiver),
56});
5763error: "Invalid URL format",
64},
65function: urlReceiver.receiveURL.bind(urlReceiver),
66});
67});
72inputs: {},
73expectedResult: undefined,
74function: urlReceiver.clearHistory.bind(urlReceiver),
75});
7679inputs: {},
80expectedResult: [],
81function: urlReceiver.getURLHistory.bind(urlReceiver),
82});
8386inputs: {},
87expectedResult: undefined,
88function: urlReceiver.clearHistory.bind(urlReceiver),
89});
9097console.log(`Running test: ${testCase.description}`);
9899const result = testCase.function(testCase.inputs.url);
100console.log(`Input: ${JSON.stringify(testCase.inputs)}`);
101console.log(`Expected result: ${JSON.stringify(testCase.expectedResult)}`);
money_countermain.tsx7 matches
3SINGLE-FILE VAL CODE
41) Imports React, once.
52) Declares CSS + server() function
63) Declares the <App/> React component
74) Declares client() to mount <App/>
298299/* ------------------------------------------------
3002) server() function: returns the HTML skeleton
301------------------------------------------------ */
302export default async function server(request: Request): Promise<Response> {
303return new Response(
304`
3283) The React App
329------------------------------------------------ */
330function App() {
331// States for inputs
332const [entryName, setEntryName] = useState("#");
365366// Helpers
367function formatNumber(num) {
368return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
369}
370function formatCurrency(num) {
371return `$${num.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, "$&,")}`;
372}
8974) Mount the React <App/> client-side
898------------------------------------------------ */
899function client() {
900createRoot(document.getElementById("root")).render(<App />);
901}
bluesky_bot_templatemain.tsx5 matches
6});
78// Helper function to convert data URI to Uint8Array
9function convertDataURIToUint8Array(dataURI: string): Uint8Array {
10const base64Data = dataURI.split(",")[1];
11const binaryString = atob(base64Data);
17}
1819// Helper function to fetch SVG and convert to base64
20async function fetchSVGAsBase64(url: string): Promise<string> {
21const response = await fetch(url);
22if (!response.ok) {
27}
2829export default async function(interval: Interval) {
30// Don't forget to set these environment variables in the val's settings.
31const username = process.env.BLUESKY_USERNAME;
templateRedditAlertmain.tsx1 match
12const isProd = true;
1314export async function redditAlert({ lastRunAt }: Interval) {
15if (!SERP_API_KEY || !DISCORD_API_KEY) {
16console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
templateTwitterAlertmain.tsx1 match
12const isProd = false;
1314export async function twitterAlert({ lastRunAt }: Interval) {
15// If isProd, search for tweets since that last time this interval ran
16// if not, search for tweets since 48 hours ago for testing
4import process from "node:process";
56export async function hnValTown({ lastRunAt }: Interval) {
7// Edit to update time frame
8const twoMonthsAgo = new Date();