slackBotExampleREADME.md1 match
45This guide walks you through creating a Slack bot that replies when mentioned in
6a channel. You'll use Val Town to host your bot and Slack's API to connect it to
7your workspace.
8
slackBotExamplemain.tsx1 match
34try {
35// Use standard fetch instead of fetchJSON for more control
36const result = await fetch("https://slack.com/api/chat.postMessage", {
37method: "POST",
38headers: {
GlancergetActions.ts1 match
3// Initialize Notion client
4const notion = new Client({
5auth: Deno.env.get("NOTION_API_KEY"),
6});
7
GlancersetAction.ts1 match
3// Initialize Notion client
4const notion = new Client({
5auth: Deno.env.get("NOTION_API_KEY"),
6});
7
GlancerdemoCobrowseStatus.ts1 match
5// Initialize Notion client
6const notion = new Client({
7auth: Deno.env.get("NOTION_API_KEY"),
8});
9
Snotel-Analyzerindex.ts17 matches
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3import type { SnotelSite, SnotelData, ApiResponse } from "../shared/types.ts";
45const app = new Hono();
20});
2122// API endpoint to get SNOTEL sites
23app.get("/api/sites", async c => {
24try {
25// Use specific Colorado SNOTEL station IDs
31
32const response = await fetch(
33`https://wcc.sc.egov.usda.gov/awdbRestApi/services/v1/stations?stationIds=${coStationIds.join(',')}`
34);
35
36if (!response.ok) {
37throw new Error(`API request failed: ${response.status}`);
38}
39
52}));
53
54const apiResponse: ApiResponse<SnotelSite[]> = {
55success: true,
56data: sites
57};
58
59return c.json(apiResponse);
60} catch (error) {
61console.error("Error fetching sites:", error);
62const apiResponse: ApiResponse<SnotelSite[]> = {
63success: false,
64error: error instanceof Error ? error.message : "Unknown error"
65};
66return c.json(apiResponse, 500);
67}
68});
6970// API endpoint to get latest data for stations
71app.get("/api/data", async c => {
72try {
73// Get current date and 30 days ago for recent data
87// Fetch recent data for these stations
88const dataResponse = await fetch(
89`https://wcc.sc.egov.usda.gov/awdbRestApi/services/v1/data?stationIds=${coStationIds.join(',')}&elementCds=SNWD,WTEQ,TOBS&ordinal=1&duration=DAILY&getFlags=false&alwaysReturnDailyFeb29=false&format=json&beginDate=${formatDate(startDate)}&endDate=${formatDate(endDate)}`
90);
91
92if (!dataResponse.ok) {
93throw new Error(`Data API request failed: ${dataResponse.status}`);
94}
95
136});
137
138const apiResponse: ApiResponse<SnotelData[]> = {
139success: true,
140data: Object.values(stationData)
141};
142
143return c.json(apiResponse);
144} catch (error) {
145console.error("Error fetching data:", error);
146const apiResponse: ApiResponse<SnotelData[]> = {
147success: false,
148error: error instanceof Error ? error.message : "Unknown error"
149};
150return c.json(apiResponse, 500);
151}
152});
Snotel-Analyzerindex.html2 matches
44// Fetch sites and data in parallel
45const [sitesResponse, dataResponse] = await Promise.all([
46fetch('/api/sites'),
47fetch('/api/data')
48]);
49
Snotel-Analyzertypes.ts1 match
24}
2526export interface ApiResponse<T> {
27success: boolean;
28data?: T;
Snotel-AnalyzerREADME.md6 matches
1# SNOTEL Data Viewer
23A web application that displays the latest SNOTEL (Snow Telemetry) data from USDA's AWDB REST API.
45## Features
7- Displays latest snow and weather data from SNOTEL sites
8- Interactive table with site information
9- Real-time data fetching from USDA AWDB API
1011## Project Structure
1213- `backend/index.ts` - Main Hono server with API endpoints
14- `frontend/index.html` - Main HTML template
15- `frontend/index.tsx` - React frontend application
16- `shared/types.ts` - Shared TypeScript types
1718## API Endpoints
1920- `GET /` - Serves the main application
21- `GET /api/sites` - Fetches SNOTEL site data
22- `GET /api/data/:stationId` - Fetches latest data for a specific station
2324## Usage