1let { apiCounter } = await import("https://esm.town/v/andreterron/apiCounter");
2
3export let incrementAPICounter = (req, res: express.Response) => {
4 apiCounter += 1;
5 res.send(JSON.stringify({ status: "Success!" }));
6};
8 const q = new URLSearchParams({ query, ...params }).toString();
9 const results = await fetchJSON(
10 `https://api.twitter.com/2/tweets/search/recent?${q}`,
11 {
12 headers: {
1export function myApi(name) {
2 return "hi " + name;
3}
3export let getPoemForTime = async (time: string) => {
4 const poemResponse = await fetch(
5 `https://poem.town/api/v1/clock/poem/${time}`
6 );
7 const poemJson = await poemResponse.json();
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export function postToMastodon(mastodonApiUrl, mastodonAccessToken, status) {
4 return fetch(
5 `${mastodonApiUrl}/statuses?access_token=${mastodonAccessToken}`,
6 {
7 headers: {
2
3export let postWebhookTest = fetchJSON(
4 "https://api.val.town/express/@ggarnhart.citiBikeSpotChecker",
5 {
6 method: "POST",
4export const chatSampleFunctionSingle = (async () => {
5 // Example dummy function hard coded to return the same weather
6 // In production, this could be your backend API or an external API
7 const getCurrentWeather = (location, unit = "fahrenheit") => ({
8 unit,
6 options = {},
7) => {
8 // Initialize OpenAI API stub
9 const { Configuration, OpenAIApi } = await import("https://esm.sh/openai");
10 const configuration = new Configuration({
11 apiKey: process.env.openAIAPI,
12 });
13 const openai = new OpenAIApi(configuration);
14 // Request chat completion
15 const messages = typeof prompt === "string"
21 };
22 capturePostHogEvent(
23 process.env.phProjectAPIKey,
24 user,
25 eventName,
1export function myApi(name) {
2 return "hi " + name;
3}