7
8// Import route modules
9import api from "./routes/api/api.routes.ts";
10import auth from "./routes/auth.ts";
11import root from "./routes/root.routes.ts";
31// Mount route modules
32app.route("/", root);
33app.route("/api", api);
34app.route("/tasks", tasks);
35app.route("/demo", demo);
13
14app.route("/auth", auth);
15app.route("/api/pipedream", pipedream);
16
17const title = "Pipedream x Val Town Connect";
11
12async function tokenCallback() {
13 const resp = await fetch("/api/pipedream/token", {
14 method: "POST",
15 });
1const API_KEY = Deno.env.get("Google_API_Key");
2const FAMILY_CALENDAR_ID = "createadrenaline.com_1m3016rurr5jufl1ic3lb03frk@group.calendar.google.com";
3
4const endpoint = `https://www.googleapis.com/calendar/v3/calendars/${
5 encodeURIComponent(FAMILY_CALENDAR_ID)
6}/events?key=${API_KEY}&orderBy=startTime&singleEvents=true&timeMin=${(new Date()).toISOString()}`;
7
8const getCalendarEvents = () =>
48 <form
49 method="POST"
50 action={`/api/pipedream/connections/${account.id}/delete`}
51 onSubmit={(e) => {
52 if (
47 <form
48 method="POST"
49 action={`/api/pipedream/triggers/${trigger.id}/delete`}
50 onSubmit={(e) => {
51 if (
1const response = await fetch("https://site.api.espn.com/apis/site/v2/sports/basketball/nba/draft");
2const data = await response.json();
3
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=44";
2// import { pipeDreamGoogle } from "https://esm.town/v/stevekrouse/pipedream";
3import { google } from "npm:googleapis";
4
5// const accountId = "apn_r5hwKnV";
8export async function getAccessToken(accountId: string, bearer = Deno.env.get("pipedream")) {
9 const response = await fetchJSON(
10 `https://api.pipedream.com/v1/accounts/${accountId}?include_credentials=1`,
11 { bearer },
12 );
24
25// export async function getCalendars(accountId: string) {
26// const calendarAPI = await pipeDreamGoogle("calendar", accountId);
27// const calendars = await calendarAPI.calendarList.list();
28// return calendars.data.items;
29// }
4
5export default function({ onLogin }) {
6 const [apiKey, setApiKey] = useState("");
7 const [isLoading, setIsLoading] = useState(false);
8 const [error, onError] = useState("");
16 method: "POST",
17 headers: { "Content-Type": "application/json" },
18 body: JSON.stringify({ apiKey }),
19 });
20 if (response.ok) window.location.href = "/";
55 <p>To login:</p>
56 <p className="ml-4">
57 1. Create an API key:{" "}
58 <a
59 href="https://www.val.town/settings/api"
60 target="_blank"
61 rel="noopener noreferrer"
62 className="text-blue-600 hover:text-blue-800 transition-colors break-all"
63 >
64 https://www.val.town/settings/api
65 </a>
66 </p>
71 <div>
72 <input
73 id="apiKey"
74 type="password"
75 value={apiKey}
76 onChange={(e) => setApiKey(e.target.value)}
77 placeholder="vt_..."
78 className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
16 }}
17 >
18 <h3 className="font-bold capitalize">
19 {item?.properties?.Name?.title?.[0]?.plain_text}
20 </h3>