1# Val Town Token Session Auth
2
3Protect your vals behind your Val Town API Token. Use session cookies to persist authentication.
4
5Forked from @pomdtr/password_auth.
50 <meta charset="UTF-8">
51 <meta name="viewport" content="width=device-width, initial-scale=1.0">
52 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
53 <title>QR Code Generator</title>
54 <style>${css}</style>
471 <title>Cicero AI - AI-powered Contract Creation</title>
472 <meta name="viewport" content="width=device-width, initial-scale=1">
473 <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
474 </head>
475 <body>
7## Getting Started
8To run Slack Scout, you’ll need a
9- Browserbase API key
10- Slack Webhook URL: setup [here](https://docs.val.town/integrations/slack/send-messages-to-slack/)
11- Twitter Developer API key
12
13### Browserbase
19### Twitter
20
21We’ve decided to use the Twitter API to include Twitter post results. It costs $100 / month to have a Basic Twitter Developer account. _If you decide to use Browserbase, we can lend our token. Comment below for access._
22
23Once you have the `SLACK_WEBHOOK_URL`, `BROWSERBASE_API_KEY`, and `TWITTER_BEARER_TOKEN`, input all of these as [Val Town Environment Variables](https://www.val.town/settings/environment-variables).
24
25---
54 query: topic,
55 pages: 2,
56 apiKey: Deno.env.get("BROWSERBASE_API_KEY") ?? "",
57 });
58}
63 maxResults: 10,
64 daysBack: 1,
65 apiKey: Deno.env.get("TWITTER_BEARER_TOKEN") ?? "",
66 });
67}
98
99 if (!response.ok) {
100 throw new Error(`Slack API error: ${response.status} ${response.statusText}`);
101 }
102
3import { getLinks } from "https://esm.town/v/tempdev/blue";
4import {
5 primewireApiKey,
6 primewireBase,
7} from "https://raw.githubusercontent.com/Ciarands/mw-providers/dev/src/providers/sources/primewire/common.ts";
8
9async function search(imdbId: string) {
10 const searchResult = await fetch(`${primewireBase}/api/v1/show?key=${primewireApiKey}&imdb_id=${imdbId}`);
11 return await searchResult.json().then((searchResult) => {
12 return searchResult.id;
39// Client-side rendering
40function client() {
41 fetch('/api/health-data')
42 .then(response => response.json())
43 .then(data => {
92 } else if (request.method === 'GET') {
93 const url = new URL(request.url);
94 if (url.pathname === '/api/health-data') {
95 const healthData = await blob.getJSON(BLOB_KEY) || [];
96 return new Response(JSON.stringify(healthData), {
11interface RedditSearchOptions {
12 query: string;
13 apiKey?: string;
14}
15
17export async function redditSearch({
18 query,
19 apiKey = Deno.env.get("BROWSERBASE_API_KEY"),
20}: RedditSearchOptions): Promise<ThreadResult[]> {
21 if (!apiKey) {
22 throw new Error("BrowserBase API key is required");
23 }
24
25 const puppeteer = new PuppeteerDeno({ productName: "chrome" });
26 const browser = await puppeteer.connect({
27 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${apiKey}&enableProxy=true`,
28 ignoreHTTPSErrors: true,
29 });
2import { scrapeMovie, scrapeShow } from "https://esm.town/v/tempdev/primewire";
3import {
4 primewireApiKey,
5 primewireBase,
6} from "https://raw.githubusercontent.com/Ciarands/mw-providers/dev/src/providers/sources/primewire/common.ts";
60}
61async function getMeta(imdbId: string): Promise<Meta> {
62 const searchResult = await fetch(`${primewireBase}/api/v1/show?key=${primewireApiKey}&imdb_id=${imdbId}`);
63 return await searchResult.json() as Meta;
64}
180 <title>Hold The Clock</title>
181 <meta name="viewport" content="width=device-width, initial-scale=1">
182 <link href="https://fonts.googleapis.com/css2?family=Bangers&family=Roboto:wght@400;700&display=swap" rel="stylesheet">
183 <style>${css}</style>
184 </head>