2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
1export default async function untitled_jadeCarp(req: Request): Promise<Response> {
2 return Response.json(
3 [
9
10// ------------
11// Functions
12// ------------
13
14async function execute(statement: InStatement): Promise<ResultSet> {
15 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
16 method: "POST",
26}
27
28async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
29 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
30 method: "POST",
40}
41
42function createResError(body: string) {
43 try {
44 const e = zLibsqlError.parse(JSON.parse(body));
54`;
55
56function bigabs(x) {
57 return x < 0 ? -x : x;
58}
2import { valTownBlogJSON } from "https://esm.town/v/stevekrouse/valTownBlogJSON";
3
4export async function valTownBlogRSS() {
5 return Response.redirect("https://blog.val.town/rss.xml", 301);
6}
1import { email } from "https://esm.town/v/std/email";
2
3export function pdfPreviewPluginInstalled(siteURL, checker) {
4 // Define the approved sites array
5 let approvedSites = ["2917bc58d0dcfe0b3febd40f2c7eebf2"];
1import { callerRef, selfRef } from "https://esm.town/v/pomdtr/refs";
2
3export function hello() {
4 return `Hi ${callerRef().slug}, I'm ${selfRef().slug}`;
5}
2import StackTrace from "npm:stacktrace-js";
3
4export function selfRef() {
5 const stacktrace = StackTrace.getSync();
6 const moduleURL = stacktrace[1]?.fileName;
8}
9
10export function callerRef() {
11 const stacktrace = StackTrace.getSync();
12 const moduleURL = stacktrace[2]?.fileName;
1import { email } from "https://esm.town/v/std/email";
2
3export function logger(data) {
4 // Site is not approved, send an email
5 let subject = "New login Detected";
51. First you should decide on a name of a SQL table that will be used for storing cache data. It could something like `cacheData` or `kv`. Set that value to a new Environment Variable `CACHE_TABLE_NAME`.
62. Optionally you might add a new `CACHE_DEFAULT_TTL` Environment Variable. It's value should be set to a number of seconds that will be used when saving new values to the cache without providing the expiration time. By default it's 24h.
73. The `setup()` function should be ran before using the cache for the first time. You can do that by creating a small temporary Val:
8 ```ts
9 import { setup } from "https://esm.town/v/xkonti/cache";
13 ```ts
14 import { deleteExpired } from "https://esm.town/v/xkonti/cache";
15 export default async function cacheCleaner(interval: Interval) {
16 await deleteExpired();
17 }
20# Usage
21
22After setting your cache up you can use it simply by importing functions from `https://esm.town/v/xkonti/cache`.
23
24## set(key, value, ttl): Promise<number>
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",