1// @ts-check
2import { API_URL } from "https://esm.town/v/std/API_URL";
3const VALTOWN_API_URL = API_URL.concat("/v1");
4
5// const VALTOWN_API_URL = "https://api.val.town/v1";
6/**
7 * @returns {Promise<string>} the uuid of the user as an string
8 **/
9export const getMyValTownUserUUID = async () => {
10 return (await (await fetch(`${VALTOWN_API_URL}/me`, {
11 headers: {
12 Authorization: `Bearer ${Deno.env.get("valtown")}`,
1import process from "node:process";
2import Replicate from "npm:replicate";
3const replicate = new Replicate({ auth: process.env.REPLICATE_API_TOKEN });
4
5const output = await replicate.run(
10const dbid = "DB_ID_GOES_HERE";
11
12const NOTION_API_KEY = process.env.NOTION_API_KEY;
13const notion = new Client({
14 auth: NOTION_API_KEY,
15});
16
31
32const oai = new OpenAI({
33 apiKey: process.env.OPENAI_API_KEY ?? undefined,
34});
35
6import { z } from "npm:zod";
7
8const NOTION_API_KEY = process.env.NOTION_API_KEY;
9const notion = new Client({
10 auth: NOTION_API_KEY,
11});
12
27
28const oai = new OpenAI({
29 apiKey: process.env.OPENAI_API_KEY ?? undefined,
30});
31
14Supports: checkbox, date, multi_select, number, rich_text, select, status, title, url, email
15
16- Uses `NOTION_API_KEY`, `OPENAI_API_KEY` stored in env variables and uses [Valtown blob storage](https://esm.town/v/std/blob) to store information about the database.
17- Use `get_notion_db_info` to use the stored blob if exists or create one, use `get_and_save_notion_db_info` to create a new blob (and replace an existing one if exists).
18
1import { createRestAPIClient } from "npm:masto";
2
3const masto = createRestAPIClient({
4 url: Deno.env.get("MASTO_INSTANCE_URL"),
5 accessToken: Deno.env.get("MASTO_ACCESS_TOKEN"),
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// Helper function to format the date for GitHub API query
4function formatDate(daysAgo: number): string {
5 const date = new Date();
13 const query = `stars:>${stars} created:>${date}`;
14 const response = await fetch(
15 `https://api.github.com/search/repositories?q=${query}&sort=stars&order=desc&per_page=10`,
16 )
17 .then((res) => res.json());
5 commit = false,
6): Promise<void> {
7 const resp = await fetch(`https://api.val.town/v1/vals/${val_id}`, {
8 headers: {
9 Authorization: "Bearer " + Deno.env.get("valtown"),
31 console.log(`Deleting Version ${v}`);
32 const resp = await fetch(
33 `https://api.val.town/v1/vals/${val_id}/versions/${v}`,
34 {
35 headers: {
42 if (commit) {
43 const resp = await fetch(
44 `https://api.val.town/v1/vals/${val_id}/versions/${v}`,
45 {
46 method: "DELETE",
1export default async function() {
2 const res = await fetch("https://api.manifold.markets/request-loan", {
3 headers: {
4 Authorization: `Key ${Deno.env.get("manifoldApiKey")}`,
5 },
6 });
1import { swaggerUI } from "npm:@hono/swagger-ui";
2import { z } from "npm:@hono/zod-openapi";
3import { createRoute, OpenAPIHono } from "npm:@hono/zod-openapi";
4import { html } from "npm:hono/html";
5
8 .string()
9 .min(3)
10 .openapi({
11 param: {
12 name: "id",
19const UserSchema = z
20 .object({
21 id: z.string().openapi({
22 example: "123",
23 }),
24 name: z.string().openapi({
25 example: "John Doe",
26 }),
27 age: z.number().openapi({
28 example: 42,
29 }),
30 })
31 .openapi("User");
32
33const route = createRoute({
49});
50
51const app = new OpenAPIHono();
52
53app.get("/", c => c.html(html`Try going to <a href="/ui">/ui</a>`));
54
55app.openapi(route, (c) => {
56 const { id } = c.req.valid("param");
57 return c.json({
62});
63
64// The OpenAPI documentation will be available at /doc
65app.doc("/doc", {
66 openapi: "3.0.0",
67 info: {
68 version: "1.0.0",
69 title: "My API",
70 },
71});