63This val uses the SocialData API for Twitter data:
64- **Proxies via Val Town's SocialDataProxy**: Limited to 100 calls/day for [**Val Town Pro users**](https://www.val.town/pricing).
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.
10const isProd = true;
11
12export async function twitterAlert({ lastRunAt }: Interval) {
13 // Scrapes data from past 48 hours time frame if testing
14 const timeFrame = isProd
1import safeJsonValue from "npm:safe-json-value";
2
3export async function evalCode(
4 code: string,
5): Promise<{ error: { message: string; name: string; stack: string } } | any> {
43}
44
45function getMainExport(
46 mod: any,
47): { ok: true; value: any } | { ok: false; error: Error } {
74}
75
76export default async function(req: Request): Promise<Response> {
77 // Use your Val Town API Token to create a session
78 const wide = new Wide(await ValSession.new(Deno.env.get("valtown")));
25);
26
27function formatPEM(b64: string, type: "PRIVATE KEY" | "PUBLIC KEY"): string {
28 const lines = b64.match(/.{1,64}/g) || [];
29 return `-----BEGIN ${type}-----\n${lines.join("\n")}\n-----END ${type}-----`;
20`;
21
22async function newSession(valTownToken: string) {
23 const privateKeyPem = `
24-----BEGIN PRIVATE KEY-----
38}
39
40function validate(token: string) {
41 const decoded = jwt.verify(token, publicKeyPem, { algorithms: ["RS256"] }) as
42 & Awaited<
25);
26
27function formatPEM(b64: string, type: "PRIVATE KEY" | "PUBLIC KEY"): string {
28 const lines = b64.match(/.{1,64}/g) || [];
29 return `-----BEGIN ${type}-----\n${lines.join("\n")}\n-----END ${type}-----`;
20`;
21
22async function newSession(valTownToken: string) {
23 const privateKeyPem = `
24-----BEGIN PRIVATE KEY-----
38}
39
40function validate(token: string) {
41 const decoded = jwt.verify(token, publicKeyPem, { algorithms: ["RS256"] }) as
42 & Awaited<
277});
278
279function Style() {
280 return (
281 <style>
294}
295
296function Logout() {
297 return (
298 <form action="/logout" method="post">
318
319/**
320 * This function can be used on its own
321 * to commit multiple files to a GitHub repo
322 */
323export async function commitFiles({
324 token,
325 owner,
64};
65
66export default async function(req: Request): Promise<Response> {
67 if (req.method === "GET") {
68 // handle a GET request