10formData.append("file", blob, "data.ts");
11
12// URL of your API
13const apiUrl = "https://filehaus.top/api/upload/data.ts"; // Replace with your API URL
14
15// Send the file using fetch
16try {
17 const response = await fetch(apiUrl, {
18 method: "POST",
19 body: formData,
1// This implementation uses SQLite to store blob data instead of the Val Town API.
2// It creates a 'blobs' table to store key-value pairs, where the key is the blob key
3// and the value is the blob data stored as TEXT. This approach allows for persistence
1// This implementation uses SQLite to store blob data instead of the Val Town API.
2// It creates a 'blobs' table to store key-value pairs, where the key is the blob key
3// and the value is the blob data stored as TEXT. This approach allows for persistence
5Using these two vals, you can put an interactive guestbook on any website.
6
7`valUser` and `valName` are used to build the Express API URL for your forked version of [`@vtdocs.guestbook`](https://www.val.town/v/vtdocs.guestbook).
11
12 try {
13 const apiUrl =
14 `https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exintro&explaintext&format=json&origin=*&titles=${
15 encodeURIComponent(title)
16 }`;
17 const response = await fetch(apiUrl);
18 if (!response.ok) {
19 throw new Error(`HTTP error! status: ${response.status}`);
1// This approach will use the Notion API to update a block's color.
2// We'll create a simple HTML page with a button, and use JavaScript to handle
3// the click event and make a request to our Val Town function.
4// The function will then make a request to the Notion API to update the block.
5
6import { Hono } from "npm:hono";
49app.post("/randomize", async (c) => {
50 const blockId = Deno.env.get("TOWNIE_BLOCK_ID");
51 const notionApiKey = Deno.env.get("TOWNIE_NOTION_API_KEY");
52
53 if (!blockId || !notionApiKey) {
54 return c.json({ message: "Missing environment variables" }, 500);
55 }
58 const randomColor = colors[Math.floor(Math.random() * colors.length)];
59
60 const response = await fetch(`https://api.notion.com/v1/blocks/${blockId}`, {
61 method: "PATCH",
62 headers: {
63 "Authorization": `Bearer ${notionApiKey}`,
64 "Notion-Version": "2022-06-28",
65 "Content-Type": "application/json",
38 model: openai("gpt-4o", {
39 baseURL: "https://std-openaiproxy.web.val.run/v1",
40 apiKey: Deno.env.get("valtown"),
41 } as any),
42 messages: [
57
58export async function exec(interval: Interval) {
59 const apiKey = Deno.env.get("LINEAR_API_KEY");
60 if (!apiKey) {
61 console.error("LINEAR_API_KEY not found in environment variables");
62 Deno.exit(1);
63 }
65 const { startDate, endDate } = getYesterdayDateRange();
66
67 const response = await fetch("https://api.linear.app/graphql", {
68 method: "POST",
69 headers: {
70 "Content-Type": "application/json",
71 Authorization: apiKey,
72 },
73 body: JSON.stringify({
80
81 if (data.errors) {
82 console.error("Error fetching data from Linear API:", data.errors);
83 Deno.exit(1);
84 }
94 }
95
96 const historyResponse = await fetch("https://api.linear.app/graphql", {
97 method: "POST",
98 headers: {
99 "Content-Type": "application/json",
100 Authorization: apiKey,
101 },
102 body: JSON.stringify({
190 }
191
192 const slackResponse = await fetch("https://slack.com/api/chat.postMessage", {
193 method: "POST",
194 headers: {
4
5[LastLogin](https://lastlogin.io/) is a decentralized hosted auth provider
6that enables login to any app through email, Google, Github, etc without API keys.
7
8This val exports middleware that can be added to any HTTP val.
2
3export let currency = async (desired, base = "usd", amount = 1) => {
4 let { rates } = await fetchJSON(`https://open.er-api.com/v6/latest/${base}`);
5 if (rates && rates[desired.toUpperCase()]) return amount * (rates[desired.toUpperCase()]);
6 else {
7 let { rates } = await fetchJSON(
8 `https://api.coingecko.com/api/v3/exchange_rates?&x_cg_demo_api_key=${Deno.env.get("COINGECKO_API_KEY")}`,
9 );
10 return amount * rates[desired.toLowerCase()]?.value / rates[base.toLowerCase()]?.value;