sqlite_adminmain.tsx1 match
10app.get("/", async (c) => c.html(await sqlite_admin_tables()));
11app.get("/:table", async (c) => c.html(await sqlite_admin_table(c.req.param("table"))));
12export default basicAuth(app.fetch, { verifyUser: (_, password) => verifyToken(password) });
getLemmyJwtmain.tsx1 match
7const { LemmyHttp } = await import("npm:lemmy-js-client@0.18.1");
8let client = new LemmyHttp(`https://${instance}`, {
9fetchFunction: fetch,
10});
11try {
102}
103104// Val Town HTTP Endpoint for Airtable → Framer Fetch
105export default async function (req: Request): Promise<Response> {
106// Setup CORS Headers for Framer Fetch compatibility
107const headers = new Headers({
108"Access-Control-Allow-Origin": "*",
123const airtableTableId = await val.secrets.AIRTABLE_TABLE_ID;
124125// Fetch all records with pagination
126let allRecords: AirtableRecord[] = [];
127let offset: string | undefined;
133}
134135const airtableResp = await fetch(url.toString(), {
136headers: {
137Authorization: `Bearer ${airtableApiKey}`,
codeOnValTownmain.tsx3 matches
3738/**
39* @param handler Fetch handler
40* @param val Define which val should open
41*/
42export function modifyFetchHandler(
43handler: (req: Request) => Response | Promise<Response>,
44{ val, style }: { val?: ValRef; style?: string } = {},
52}
5354export default modifyFetchHandler;
codeOnValTownREADME.md6 matches
11Here are 2 different ways to add the "Code on Val Town" ribbon:
1213### 1. Wrap your fetch handler (recommended)
1415```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
1819export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
5253- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
5558You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
5960- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
626465```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67.github-fork-ribbon {
68display: none !important;
contentTemplateAppmain.tsx19 matches
5354useEffect(() => {
55fetchContent();
56}, []);
5758const fetchContent = async () => {
59try {
60const response = await fetch("/api/content");
61const data = await response.json();
62if (data.records) {
63setContent(data.records);
64} else {
65throw new Error("Failed to fetch content");
66}
67setLoading(false);
68} catch (error) {
69console.error("Error fetching content:", error);
70setLoading(false);
71}
99const analyzeContent = async (item: AirtableRecord) => {
100try {
101const response = await fetch("/api/analyze", {
102method: "POST",
103headers: {
260261try {
262const response = await fetch(airtableUrl, {
263headers: {
264'Authorization': `Bearer ${apiToken}`,
274return new Response(JSON.stringify(data), { headers });
275} catch (error) {
276console.error("Error fetching Airtable data:", error);
277return new Response(JSON.stringify({ error: "Error fetching data from Airtable" }), {
278status: 500,
279headers
368// Example 2: Making an API call to /api/content endpoint
369/*
370async function fetchContent() {
371try {
372const response = await fetch('https://awhitter-contenttemplateapp.web.val.run/api/content');
373const data = await response.json();
374console.log('Content:', data);
375// Process the data as needed
376} catch (error) {
377console.error('Error fetching content:', error);
378}
379}
380381fetchContent();
382*/
383427*/
428429// Example 5: Using the endpoint in Framer with fetch
430/*
431// In your Framer project, create a new code component and use the following code:
433import { Data, animate, Override, Animatable } from "framer"
434435// This function fetches the content from the API
436async function fetchContent() {
437try {
438const response = await fetch('https://awhitter-contenttemplateapp.web.val.run/api/content')
439const data = await response.json()
440return data.records
441} catch (error) {
442console.error('Error fetching content:', error)
443return []
444}
450451Data.useEffect(() => {
452fetchContent().then(setContent)
453}, [])
454
694695// just launch it, don't wait for the result
696// const taskRunResponse = await fetch(`${URL}/taskrun`, {
697const taskRunResponse = fetch(`${URL}/taskrun`, {
698method: "POST",
699headers: {
785}
786787export default app.fetch;
788export { ai, ModelProvider, modelProvider, test };
12
13try {
14const response = await fetch(url);
15const data = await response.json();
16return data;
8import { API_URL } from "https://esm.town/v/std/API_URL";
910const response = await fetch(`${API_URL}/v1/me`, {
11headers: {
12Authorization: `Bearer ${Deno.env.get("valtown")}`,
3536async function execute(statement: InStatement): Promise<ResultSet> {
37const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38method: "POST",
39headers: {
4950async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
51const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
52method: "POST",
53headers: {