7// Create login schema with email and password
8const inputSchema = v.pipe(v.array(v.pipe(v.string(), v.minLength(1), v.maxLength(32))), v.minLength(1), v.maxLength())
9const client = new VoyageAIClient({ apiKey: Deno.env.get("VOYAGE_API_TOKEN") })
10
11let working = false
29
30 const openai = new OpenAI({
31 baseURL: "https://openrouter.ai/api/v1",
32 apiKey: Deno.env.get("OPEN_ROUTER_KEY"),
33 });
34 console.log(messages);
26 * DO NOT use the alert(), prompt(), or confirm() methods.
27
28 * If the user's app needs weather data, use open-meteo unless otherwise specified because it doesn't require any API keys.
29
30 * Tastefully add a view source link back to the user's val if there's a natural spot for it. Generate the val source url via `import.meta.url.replace("esm.town", "val.town")`. This link element should include a target="_top" attribute.
38 Val Town's client-side catch script automatically catches client-side errors to aid in debugging.
39
40 * Don't use any environment variables unless strictly necessary. For example use APIs that don't require a key.
41 If you need environment variables use `Deno.env.get('keyname')`
42
4// Create login schema with email and password
5const inputSchema = v.pipe(v.array(v.pipe(v.string(), v.minLength(1), v.maxLength(32))), v.maxLength(4))
6const client = new VoyageAIClient({ apiKey: Deno.env.get("VOYAGE_API_TOKEN") })
7
8let working = false
1import process from "node:process";
2import { AppBskyFeedPost, AtpAgent } from "npm:@atproto/api";
3
4const agent = new AtpAgent({
1import { searchWithSerpApi } from "https://esm.town/v/charmaine/searchWithSerpApi";
2import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
3
4// Customize your search parameters
5const KEYWORDS = "\"node\" OR \"node.js\"";
6const DISCORD_API_KEY = Deno.env.get("mentionsDiscord");
7const SERP_API_KEY = Deno.env.get("SERP_API_KEY");
8
9// Set isProd = false for testing and = true for production
13
14export async function redditAlert({ lastRunAt }: Interval) {
15 if (!SERP_API_KEY || !DISCORD_API_KEY) {
16 console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
17 return;
18 }
19
20 // Determine the time frame for the search
21 // Details on as_qdr: https://serpapi.com/advanced-google-query-parameters#api-parameters-advanced-search-query-parameters-as-qdr
22 const timeFrame = isProd
23 ? lastRunAt
27
28 try {
29 const response = await searchWithSerpApi({
30 query: KEYWORDS,
31 site: "reddit.com",
32 apiKey: SERP_API_KEY,
33 as_qdr: timeFrame,
34 });
62 if (isProd) {
63 await discordWebhook({
64 url: DISCORD_API_KEY,
65 content,
66 });
1export async function searchWithSerpApi({
2 query,
3 site,
4 daysBack,
5 apiKey,
6}: {
7 query: string;
8 site?: string;
9 daysBack?: number;
10 apiKey: string;
11}): Promise<SearchResult[]> {
12 if (!apiKey) {
13 console.warn("SERP API key not provided. Skipping search.");
14 return [];
15 }
21
22 const encodedQuery = encodeURIComponent(`${query} ${site ? `site:${site}` : ""} after:${formattedDate}`);
23 const url = `https://serpapi.com/search.json?engine=google&q=${encodedQuery}&api_key=${apiKey}&sort_by=date`;
24
25 try {
36 }));
37 } catch (error) {
38 console.error("Error occurred during SERP API search:", error);
39 return [];
40 }
17 <p>
18 We've recently made improvements to Val Town's security by
19 <a href="https://blog.val.town/blog/api-token-scopes" target="_blank" rel="noopener noreferrer">
20 providing granular control over val permissions</a>.
21 As part of the rollout, we updated all vals to a safer set of default permissions.
6const stripe = new Stripe(
7 Deno.env.get("TEST_STRIPE_SECRET") as string,
8 { apiVersion: "2023-10-16" },
9);
10
8
9const stripe = new Stripe(Deno.env.get("stripe_sk_customer_readonly") as string, {
10 apiVersion: "2020-08-27",
11});
12