Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7Bsuccess?q=function&page=10&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 31569 results for "function"(4005ms)

factoid-triviaWelcomeMessage.tsx1 match

@bmitchinsonโ€ขUpdated 1 day ago
8}
9
10export function WelcomeMessage({ user, onLeave }: WelcomeMessageProps) {
11 return (
12 <div className="usps-card flex flex-row justify-between">

reddit-checkerREADME.md4 matches

@sunnyatlightswitchโ€ขUpdated 1 day ago
76```
77
78#### Test Full Functionality โœ… VERIFIED (Multi-subreddit support added)
79```
80GET /test-reddit-api.ts?action=test&client_id=151sZ8h5TaHVZGZZn0rOhA&subreddit=lovable
170### Adjusting Post Limit
171
172Modify the `limit` parameter in the `fetchSubredditPosts` function call:
173
174```typescript
187
188- โœ… Reddit API authentication working
189- โœ… Post fetching functional across multiple subreddits
190- โœ… Keyword matching operational
191- โœ… Slack notifications configured and tested
235## ๐Ÿ”„ Backup Options
236
237The project includes an RSS-based monitor (`reddit-rss-monitor.ts`) as a backup option if the API approach encounters issues. The RSS monitor has similar functionality but uses Reddit's RSS feeds instead of the official API.
74 * Gets an access token from Reddit API
75 */
76async function getRedditAccessToken(): Promise<string> {
77 try {
78 // Check if we have a cached token
117 * Fetches recent posts from a subreddit using Reddit API
118 */
119async function fetchSubredditPosts(subreddit: string, limit: number = 25): Promise<RedditPost[]> {
120 try {
121 const accessToken = await getRedditAccessToken();
144 * Checks if a post contains any of the specified keywords
145 */
146function containsKeywords(post: RedditPost, keywords: string[]): boolean {
147 const searchText = `${post.title} ${post.selftext}`.toLowerCase();
148 return keywords.some(keyword => searchText.includes(keyword.toLowerCase()));
152 * Formats a post for Slack notification
153 */
154function formatPostForSlack(post: RedditPost, matchedKeywords: string[]): any {
155 const redditUrl = `https://www.reddit.com${post.permalink}`;
156 const createdDate = new Date(post.created_utc * 1000).toLocaleString();
196 * Sends notification to Slack
197 */
198async function sendSlackNotification(matchingPosts: Array<{ post: RedditPost; keywords: string[] }>): Promise<void> {
199 const attachments = matchingPosts.map(({ post, keywords }) =>
200 formatPostForSlack(post, keywords)
228 * Gets the last checked timestamp from storage
229 */
230async function getLastChecked(): Promise<number> {
231 try {
232 const data = await blob.getJSON("reddit_api_monitor_last_checked");
240 * Saves the last checked timestamp to storage
241 */
242async function saveLastChecked(timestamp: number): Promise<void> {
243 await blob.setJSON("reddit_api_monitor_last_checked", { timestamp });
244}
245
246/**
247 * Main monitoring function
248 */
249export default async function() {
250 console.log(`๐Ÿ” Starting Reddit API monitor for ${CONFIG.subreddits.length} subreddits`);
251 console.log(`๐Ÿ“‹ Subreddits: ${CONFIG.subreddits.map(s => `r/${s}`).join(', ')}`);

reddit-checkertest-slack.ts2 matches

@sunnyatlightswitchโ€ขUpdated 1 day ago
21 * Formats a post for Slack notification
22 */
23function formatPostForSlack(post: RedditPost, matchedKeywords: string[]): any {
24 const redditUrl = `https://www.reddit.com${post.permalink}`;
25 const createdDate = new Date(post.created_utc * 1000).toLocaleString();
65 * Test Slack webhook
66 */
67export default async function(req: Request) {
68 const url = new URL(req.url);
69 const action = url.searchParams.get('action') || 'simple';

reddit-checkerconfig-manager.ts3 matches

@sunnyatlightswitchโ€ขUpdated 1 day ago
37 * Get current configuration
38 */
39async function getConfig(): Promise<ConfigData> {
40 try {
41 const data = await blob.getJSON("reddit_monitor_config");
55 * Save configuration
56 */
57async function saveConfig(configData: ConfigData): Promise<void> {
58 configData.lastUpdated = new Date().toISOString();
59 await blob.setJSON("reddit_monitor_config", configData);
63 * Configuration management API
64 */
65export default async function(req: Request) {
66 const url = new URL(req.url);
67 const action = url.searchParams.get('action') || 'list';

reddit-checkertest-reddit-api.ts4 matches

@sunnyatlightswitchโ€ขUpdated 1 day ago
38 * Gets an access token from Reddit API
39 */
40async function getRedditAccessToken(clientId: string, clientSecret: string): Promise<string> {
41 try {
42 const auth = btoa(`${clientId}:${clientSecret}`);
68 * Fetches recent posts from a subreddit using Reddit API
69 */
70async function fetchSubredditPosts(accessToken: string, subreddit: string, limit: number = 10): Promise<RedditPost[]> {
71 try {
72 const url = `https://oauth.reddit.com/r/${subreddit}/new?limit=${limit}`;
95 * Test the Reddit API connection
96 */
97export default async function(req: Request) {
98 const url = new URL(req.url);
99 const action = url.searchParams.get('action') || 'help';
156 }
157
158 // Test full functionality
159 console.log(`๐Ÿ” Testing Reddit API connection for r/${subreddit}...`);
160 const accessToken = await getRedditAccessToken(clientId, clientSecret);
3 */
4
5// Import the main monitor function
6import monitor from "./reddit-api-monitor.ts";
7
8export default async function(req: Request) {
9 const url = new URL(req.url);
10 const action = url.searchParams.get('action') || 'run';
1/**
2 * Test script for Reddit RSS Monitor
3 * This allows manual testing of the Reddit RSS monitoring functionality
4 */
5
18 * Parses RSS/Atom XML and extracts items
19 */
20function parseRSS(xmlText: string): RSSItem[] {
21 const items: RSSItem[] = [];
22
95 * Fetches RSS feed from a subreddit
96 */
97async function fetchSubredditRSS(subreddit: string): Promise<RSSItem[]> {
98 try {
99 const url = `https://www.reddit.com/r/${subreddit}/new.rss`;
122 * Converts RSS pubDate to timestamp
123 */
124function parseRSSDate(pubDate: string): number {
125 try {
126 return Math.floor(new Date(pubDate).getTime() / 1000);
133 * Test the Reddit RSS connection and keyword matching
134 */
135export default async function(req: Request) {
136 const url = new URL(req.url);
137 const action = url.searchParams.get('action') || 'test';
31 * Parses RSS/Atom XML and extracts items
32 */
33function parseRSS(xmlText: string): RSSItem[] {
34 const items: RSSItem[] = [];
35
108 * Fetches RSS feed from a subreddit
109 */
110async function fetchSubredditRSS(subreddit: string): Promise<RSSItem[]> {
111 try {
112 const url = `https://www.reddit.com/r/${subreddit}/new.rss`;
135 * Checks if an RSS item contains any of the specified keywords
136 */
137function containsKeywords(item: RSSItem, keywords: string[]): boolean {
138 const searchText = `${item.title} ${item.description}`.toLowerCase();
139 return keywords.some(keyword => searchText.includes(keyword.toLowerCase()));
143 * Converts RSS pubDate to timestamp
144 */
145function parseRSSDate(pubDate: string): number {
146 try {
147 return Math.floor(new Date(pubDate).getTime() / 1000);
154 * Formats an RSS item for notification
155 */
156function formatRSSItem(item: RSSItem, matchedKeywords: string[]): string {
157 const pubDate = new Date(item.pubDate).toLocaleString();
158
184 * Gets the last checked timestamp from storage
185 */
186async function getLastChecked(): Promise<number> {
187 try {
188 const data = await blob.getJSON("reddit_rss_monitor_last_checked");
196 * Saves the last checked timestamp to storage
197 */
198async function saveLastChecked(timestamp: number): Promise<void> {
199 await blob.setJSON("reddit_rss_monitor_last_checked", { timestamp });
200}
201
202/**
203 * Main monitoring function
204 */
205export default async function() {
206 console.log(`๐Ÿ” Starting Reddit RSS monitor for r/${CONFIG.subreddit}`);
207 console.log(`๐Ÿ“‹ Keywords: ${CONFIG.keywords.join(', ')}`);
1/**
2 * Test script for Reddit Monitor
3 * This allows manual testing of the Reddit monitoring functionality
4 */
5
29 * Fetches recent posts from a subreddit
30 */
31async function fetchSubredditPosts(subreddit: string, limit: number = 10): Promise<RedditPost[]> {
32 try {
33 const url = `https://www.reddit.com/r/${subreddit}/new.json?limit=${limit}`;
57 * Test the Reddit API connection and keyword matching
58 */
59export default async function(req: Request) {
60 const url = new URL(req.url);
61 const action = url.searchParams.get('action') || 'test';
tuna

tuna9 file matches

@jxnblkโ€ขUpdated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserโ€ขUpdated 2 months ago
A helper function to build a file's email
lost1991
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": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.