1export function myApi(name) {
2 return "hi " + name;
3}
1export function myApi(name) {
2 return "hi " + name;
3}
1export let capitalizeWord = async (word) => {
2 const { capitalize } = await import("npm:lodash-es");
3 return capitalize(word);
4};
3/**
4 * Calls the OpenAI moderation model. Useful for determining if OpenAI will flag something you did.
5 * https://platform.openai.com/docs/api-reference/moderations
6 */
7export let openAiModeration = async ({
8 apiKey,
9 input,
10 model,
11}: {
12 apiKey: string,
13 input: string|string[],
14 model?: "text-moderation-latest" | "text-moderation-stable",
15}) => {
16 if (!apiKey) {
17 throw new Error("You must provide an OpenAI API Key");
18 }
19 const body: { model?: string, input: string|string[] } = {
24 }
25 const result = await fetchJSON(
26 "https://api.openai.com/v1/moderations",
27 {
28 method: "POST",
29 headers: {
30 Authorization: `Bearer ${apiKey}`,
31 },
32 body: JSON.stringify(body),
1export function myApi(url) {
2 return "https://tldrify.com/ajaxproxy?url=" + url;
3}
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: {