eink-framefetchWithCache.ts1 match
6};
78export default async function fetchWithCache(
9apiUrl: string,
10cacheKey: string,
eink-framecomponents.tsx7 matches
45// Display components can be used to change the look and feel of each frame.
6export function Header({ title = "Eink" }) {
7return (
8<head>
39}
4041export function Footer() {
42const currentDate = new Date().toLocaleDateString("en-US", {
43timeZone: "America/Los_Angeles",
62}
6364export function Headline({ text = "Headline missing" }: { text: string }) {
65return (
66<div className="flex justify-between items-center p-5">
70}
7172export function Content(props: any) {
73return <div className="relative p-5 overflow-none">{props.children}</div>;
74}
7576export function BodyWrapper(props: any) {
77return (
78<body className="bg-black p-0 m-0">
84}
8586export function App() {
87return (
88<html>
99}
100101export default async function(): Promise<Response> {
102const html = renderToString(<App />);
103
eink-frameapod.tsx2 matches
67// Displays NASA's astronomy photo of the day
8function Render({ data }: { data: APOD }) {
9return (
10<html>
25}
2627export default async function(req: Request): Promise<Response> {
28const data: APOD = await GetAPOD(req).then((res: any) => res.json());
29const html = renderToString(<Render data={data} />);
eink-frameapod.ts1 match
13const NASA_API_KEY = Deno.env.get("NASA_API_KEY");
1415export default async function GetAPOD(req: Request): Promise<Response> {
16const url = `https://api.nasa.gov/planetary/apod?api_key=${NASA_API_KEY}&thumbs=true`;
17const cacheKey = "nasa_apod";
snippetshtml_with_hono.tsx1 match
55});
5657export default async function(req: Request): Promise<Response> {
58return app.fetch(req);
59}
snippetsrandomNumber.tsx1 match
1export default function server(request: Request): Response {
2const randomNumber = Math.floor(Math.random() * 100) + 1;
3const responseData = { randomNumber: randomNumber };
mod-interview-apiapi.js1 match
1// export default async function (req: Request): Promise<Response> {
23// if (req.url)
a4595dc5b24_handleTelegramMessage.ts5 matches
36* Store a chat message in the database
37*/
38export async function storeChatMessage(
39chatId,
40senderId,
69* Retrieve chat history for a specific chat
70*/
71export async function getChatHistory(chatId, limit = 50) {
72try {
73const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
94* Format chat history for Anthropic API
95*/
96function formatChatHistoryForAI(history) {
97const messages = [];
98118* Analyze a Telegram message and extract memories from it
119*/
120async function analyzeMessageContent(
121anthropic,
122username,
499500// Handle webhook requests
501export default async function (req: Request): Promise<Response> {
502// Set webhook if it is not set yet
503if (!isEndpointSet) {
a4595dc5b24_getWeather.ts5 matches
8const TABLE_NAME = `memories`;
910function summarizeWeather(weather: WeatherResponse) {
11const summarizeDay = (day: WeatherResponse["weather"][number]) => ({
12date: day.date,
25}
2627async function generateConciseWeatherSummary(weatherDay) {
28try {
29// Get API key from environment
83}
8485async function deleteExistingForecast(date: string) {
86await sqlite.execute(
87`
93}
9495async function insertForecast(date: string, forecast: string) {
96const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
97112}
113114export default async function getWeatherForecast(interval: number) {
115const weather = await getWeather("Washington, DC");
116console.log({ weather });
a4595dc5b24_generateFunFacts.ts8 matches
11* @returns Array of previous fun facts
12*/
13async function getPreviousFunFacts() {
14try {
15const result = await sqlite.execute(
32* @param dates Array of date strings in ISO format
33*/
34async function deleteExistingFunFacts(dates) {
35try {
36for (const date of dates) {
51* @param factText The fun fact text
52*/
53async function insertFunFact(date, factText) {
54try {
55await sqlite.execute(
75* @returns Array of generated fun facts
76*/
77async function generateFunFacts(previousFacts) {
78try {
79// Get API key from environment
197* @returns Array of parsed facts
198*/
199function parseFallbackFacts(responseText, expectedDates) {
200// Try to extract facts using regex
201const factPattern = /(\d{4}-\d{2}-\d{2})["']?[,:]?\s*["']?(.*?)["']?[,}]/gs;
260261/**
262* Main function to generate and store fun facts for the next 7 days
263*/
264export async function generateAndStoreFunFacts() {
265try {
266// Get previous fun facts
301* Intended to be used as a Val Town cron job
302*/
303export default async function() {
304console.log("Running fun facts generation cron job...");
305return await generateAndStoreFunFacts();