10import { exportSQLiteTable, SQLiteTableExportFormat } from "https://esm.town/v/rlesser/sqliteTableExportUtils";
11
12export default async function(req: Request): Promise<Response> {
13 const tableName = new URL(req.url).searchParams.get("table");
14 if (!tableName) {
9
10// Copied from https://github.com/Will-Howard/manifolio/blob/master/manifolio-ui/lib/calculate.ts
11function calculateNaiveKellyBet({
12 marketProb,
13 estimatedProb,
34}
35
36async function getMarket(slug: string) {
37 const res = await fetch(`https://api.manifold.markets/v0/slug/${slug}`);
38
45}
46
47export default async function(req: Request): Promise<Response> {
48 const searchParams = new URL(req.url).searchParams;
49 const params = paramsSchema.parse(Object.fromEntries(searchParams.entries())) as z.infer<typeof paramsSchema>;
17[🔬️ inspect ASP JWT token](https://vladimyr-aspe_inspector.web.val.run/aspe:keyoxide.org:TOICV3SYXNJP7E4P5AOK5DHW44)
18
19Badge with new ASPE URI (not functional yet ⚠️):
20[](https://keyoxide.org/aspe:fe7b75c54b95ac019dd48fbefe8d654af383cbfe)
21
11});
12
13async function getKnownThreads() {
14 const result = await db.select().from(threadsTbl);
15 return result.reduce((r, { id, last_message_id }) => {
19}
20
21async function getNewThreads() {
22 const resp = await fetch(`https://discord.com/api/guilds/${guild}/threads/active`, {
23 headers: {
34}
35
36export async function getThreadsActivity(
37 token: string,
38 guild: string,
3import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
4
5export default async function(ctx: BrowserContext<{ author: string; name: string }>) {
6 const { author, name } = ctx.params;
7 const title = `@${author}/${name}`;
1# RPC
2
3Turn any function into an API! This lets you call a function in Val Town without manually handling a `Request` or `Response` object.
4
5This val can be used as a replacement for the Run API, which implicitly did something similar.
6
7## Create an API from your function:
8
9This is how you can expose a function as an API:
10
111. Create an HTTP handler val
122. Import this val
133. Call `rpc` with your function as an argument
14
15Here's an example from @std/rpc_example:
34## Send a request to your val
35
36You can invoke that function from your client or your local machine with an HTTP request. You can either use a GET or a POST request, passing arguments in the query parameters or the body respectively. Make sure your val's privacy is set to Unlisted or Public.
37
38**GET request**
1import { html } from "https://esm.town/v/stevekrouse/html?v=5";
2
3export default function() {
4 return html(`
5 <body
61});
62
63async function findMyArticles() {
64 let { data: articles } = await api(`/v1/search/vals?query=${encodeURIComponent("#blog")}`);
65
5import { html } from "https://esm.town/v/stevekrouse/html?v=5";
6
7export async function exampleArticle(req: Request) {
8 const { author, name } = extractValInfo(import.meta.url);
9
1export function extractMetadata(name: string, code: string) {
2 const regex = `// ${name}: (.+)`;
3 const match = code.match(regex);
A helper function to build a file's email
Simple functional CSS library for Val Town
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.