56## How It Works
571. The cron job runs every morning
582. It fetches your calendar events for the day
593. It identifies meetings with exactly one external participant (not from your team domain)
604. For each user meeting, it:
1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { nominatimSearch } from "https://esm.town/v/stevekrouse/nominatimSearch";
4import { weatherGovGrid } from "https://esm.town/v/stevekrouse/weatherGovGrid";
13 lon,
14 });
15 let { properties: { periods } } = await fetchJSON(
16 grid.forecastHourly,
17 );
43
44 try {
45 const response = await fetch("/chat", {
46 method: "POST",
47 body: JSON.stringify({
59
60 useEffect(() => {
61 const fetchMessages = async () => {
62 try {
63 const response = await fetch("/chat");
64 const messages = await response.json();
65 setChatMessages(messages);
66 } catch (error) {
67 console.error("Fetch messages error:", error);
68 }
69 };
70 fetchMessages();
71 }, [mood]);
72
43
44 try {
45 const response = await fetch("/chat", {
46 method: "POST",
47 body: JSON.stringify({
59
60 useEffect(() => {
61 const fetchMessages = async () => {
62 try {
63 const response = await fetch("/chat");
64 const messages = await response.json();
65 setChatMessages(messages);
66 } catch (error) {
67 console.error("Fetch messages error:", error);
68 }
69 };
70 fetchMessages();
71 }, [mood]);
72
43
44 try {
45 const response = await fetch("/chat", {
46 method: "POST",
47 body: JSON.stringify({
59
60 useEffect(() => {
61 const fetchMessages = async () => {
62 try {
63 const response = await fetch("/chat");
64 const messages = await response.json();
65 setChatMessages(messages);
66 } catch (error) {
67 console.error("Fetch messages error:", error);
68 }
69 };
70 fetchMessages();
71 }, [mood]);
72
70 // Save to backend
71 try {
72 const response = await fetch('/save-schedule', {
73 method: 'POST',
74 headers: { 'Content-Type': 'application/json' },
103 // Save to backend
104 try {
105 const response = await fetch('/save-schedule', {
106 method: 'POST',
107 headers: { 'Content-Type': 'application/json' },
122 // Update backend
123 try {
124 const response = await fetch('/save-schedule', {
125 method: 'POST',
126 headers: { 'Content-Type': 'application/json' },
149 // Update backend
150 try {
151 const response = await fetch('/save-schedule', {
152 method: 'POST',
153 headers: { 'Content-Type': 'application/json' },
163
164 useEffect(() => {
165 // Fetch existing schedule on component mount
166 const fetchSchedule = async () => {
167 try {
168 const response = await fetch('/get-schedule');
169 const savedData = await response.json();
170 if (savedData) {
173 }
174 } catch (error) {
175 console.error('Failed to fetch schedule', error);
176 }
177 };
178
179 fetchSchedule();
180 }, []);
181
43
44 try {
45 const response = await fetch("/chat", {
46 method: "POST",
47 body: JSON.stringify({
59
60 useEffect(() => {
61 const fetchMessages = async () => {
62 try {
63 const response = await fetch("/chat");
64 const messages = await response.json();
65 setChatMessages(messages);
66 } catch (error) {
67 console.error("Fetch messages error:", error);
68 }
69 };
70 fetchMessages();
71 }, [mood]);
72
1const baseUrl = "https://api.neynar.com/v2/farcaster/";
2
3export async function fetchNeynarGet(path: string) {
4 const res = await fetch(baseUrl + path, {
5 method: "GET",
6 headers: {
14}
15
16export function fetchUser(username: string) {
17 return fetchNeynarGet(`user/by_username?username=${username}`).then(r => r.user);
18}
19export function fetchUsersById(fids: string) {
20 return fetchNeynarGet(`user/bulk?fids=${fids}`).then(r => r.users);
21}
22
23export function fetchUserFeed(fid: number) {
24 return fetchNeynarGet(
25 `feed?feed_type=filter&filter_type=fids&fids=${fid}&with_recasts=false&with_replies=false&limit=100&cursor=`,
26 ).then(r => r.casts);
27}
28
29export function fetchChannel(channelId: string) {
30 return fetchNeynarGet(`channel?id=${channelId}`).then(r => r.channel);
31}
32
33export function fetchChannelFeed(channelId: string) {
34 return fetchNeynarGet(
35 `feed/channels?channel_ids=${channelId}&with_recasts=false&limit=100`,
36 ).then(r => r.casts);
37}
38
39export function fetchChannelsFeed(channelIds: array) {
40 return fetchNeynarGet(
41 `feed/channels?channel_ids=${channelIds.join(",")}&with_recasts=false&limit=100`,
42 ).then(r => r.casts);
63});
64
65// HTTP vals expect an exported "fetch handler"
66// This is how you "run the server" in Val Town with Hono
67export default app.fetch;
75 const fontPromises = fontsConfig.map(async (font) => {
76 const fontUrl = "https://cdn.jsdelivr.net/npm/@tamagui/font-inter@1.108.3/otf/" + font.fontFile;
77 const fontArrayBuf = await fetch(fontUrl).then((res) => res.arrayBuffer());
78 return { name: font.name, data: fontArrayBuf, weight: font.weight };
79 });
86 // const api = `https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${code.toLowerCase()}.svg`
87 const api = `https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${code.toLowerCase()}_color.svg`;
88 return fetch(api).then((r) => r.text());
89};
90