4const location = "prospect heights, brooklyn"; // <-- change to place, city, or zip code
5
6export async function aqi(interval: Interval) {
7 const data = await easyAQI({ location });
8 if (!interval.lastRunAt) {
48const cacheKey = (location: string) => "easyAQI_v3_" + encodeURIComponent(location);
49
50export async function openAqNowcastAQI(location) {
51 const sensorID = location.sensors.find(s => s.parameter.name === "pm25").id;
52 const data = await fetchJSON(
64}
65
66export async function easyAQI({ location }: {
67 location: string;
68}) {
1export default async function(interval: Interval) {
2 fsdf;
3}
6 * Check if an email belongs to a team member
7 */
8function isTeamMember(email: string): boolean {
9 const teamDomain = Deno.env.get("TEAM_DOMAIN") || "val.town";
10 // Make sure we're doing a case-insensitive comparison
13
14/**
15 * Main function that runs every morning to check for user meetings
16 * and create Notion pages for meeting prep.
17 */
18export default async function() {
19 console.log("Running calendar to Notion sync...");
20
1const TARGET_URL = "https://api.openaq.org";
2
3export default async function(req: Request): Promise<Response> {
4 const url = new URL(req.url);
5 return fetch(TARGET_URL + url.pathname + url.search, {
50## Project Structure
51- `index.ts`: Main cron job that runs daily
52- `googleCalendar.ts`: Functions for interacting with Google Calendar API
53- `notion.ts`: Functions for creating and updating Notion pages
54- `userInfo.ts`: Functions for gathering information about meeting participants
55
56## How It Works
36 * Get a fresh access token using the refresh token
37 */
38async function getAccessToken(): Promise<string> {
39 const clientId = Deno.env.get("GOOGLE_CLIENT_ID");
40 const clientSecret = Deno.env.get("GOOGLE_CLIENT_SECRET");
69 * Fetch today's calendar events from Google Calendar
70 */
71async function fetchCalendarEvents(): Promise<GoogleCalendarEvent[]> {
72 const accessToken = await getAccessToken();
73
100 * Check if an email belongs to a team member
101 */
102function isTeamMember(email: string): boolean {
103 const teamDomain = Deno.env.get("TEAM_DOMAIN") || "val.town";
104
127 * Process calendar events to identify user meetings
128 */
129export async function fetchTodaysMeetings(): Promise<Meeting[]> {
130 const events = await fetchCalendarEvents();
131 const teamDomain = Deno.env.get("TEAM_DOMAIN") || "val.town";
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export function nominatimSearch(params: Search): Promise<Place[]> {
4 return fetchJSON(
5 "https://nominatim.openstreetmap.org/search?"
35};
36
37function httpsify(url: string) {
38 if (url.startsWith("https://"))
39 return url;
1/**
2 * Functions for gathering information about meeting participants using SERP API
3 */
4
20 * Try to get user information from SERP API
21 */
22async function tryGetSerpApiInfo(email: string, name?: string): Promise<UserInfo | null> {
23 const serpApiKey = Deno.env.get("SERP_API_KEY");
24
135 * Try to get company information from domain of email
136 */
137async function tryGetCompanyInfo(email: string): Promise<UserInfo | null> {
138 const domain = email.split('@')[1];
139
193 * Fallback to basic information from email
194 */
195function getBasicUserInfo(email: string, name?: string): UserInfo {
196 const domain = email.split('@')[1];
197 const localPart = email.split('@')[0];
220 * Get information about a user from their email address
221 */
222export async function getUserInfo(email: string, name?: string): Promise<UserInfo> {
223 // Try to get detailed information from SERP API
224 const serpInfo = await tryGetSerpApiInfo(email, name);