2import { db } from "./db.ts";
3
4export async function createTables() {
5 // Uncomment to reset database
6 // await db.run(sql`DROP TABLE IF EXISTS messages`);
9const CACHE_TTL = 3600000; // 1 hour
10
11export async function validateToken(token: string): Promise<AuthContext | null> {
12 console.log(`🔐 Validating token: ${token.substring(0, 20)}... (length: ${token.length})`);
13
8
9// Middleware for authentication
10async function authenticateRequest(c: any) {
11 const authHeader = c.req.header("Authorization");
12 if (!authHeader || !authHeader.startsWith("Bearer ")) {
9// if(request.query.code == process.env.SECRET) {
10
11export default async function(req: Request): Promise<Response> {
12 const url = new URL(req.url);
13 const query = url.searchParams;
6// import { serveFile } from "../index.ts";
7
8export function staticHTTPServer(importMetaURL: string) {
9 const app = new Hono();
10 app.get("/", () => serveFile("/index.html", importMetaURL));
50 <script>
51 let numbers = [];
52 function enterCode(code) {
53 numbers.push("" + code);
54 if (numbers.length > 4) {
115 * Creates a payment string in SEPA format for QR code generation
116 */
117function createPaymentString({ name, iban, bic, amount, reference }: {
118 name: string;
119 iban: string;
143 * Generates QR code as SVG using a QR code library
144 */
145async function generateQRCodeSVG(data: string): Promise<string> {
146 // Using qrcode library from esm.sh
147 const QRCode = await import("https://esm.sh/qrcode@1.5.3");
9const WARDROBE_KEY = "wardrobe_items"; // NEW ← pick any key name you like
10
11export default async function(req: Request): Promise<Response> {
12 // --- always hydrate the in‑memory array from storage first -------------
13 wardrobe = (await blob.getJSON<WardrobeItem[]>(WARDROBE_KEY)) ?? [];
60}
61
62// Validation functions
63export function validateCheckinRecord(record: any): CheckinRecord {
64 if (typeof record !== "object" || record === null) {
65 throw new Error("Record must be an object");
121}
122
123function validateGeoLocation(location: any): CommunityGeoLocation {
124 if (!location.latitude || typeof location.latitude !== "string") {
125 throw new Error("geo location must have latitude as string");
149}
150
151function validateAddressLocation(location: any): CommunityAddressLocation {
152 const validatedAddress: CommunityAddressLocation = {
153 $type: "community.lexicon.location.address",
200}
201
202// Utility functions
203export function generateRkey(): string {
204 return crypto.randomUUID();
205}
206
207export function createAtUri(did: string, collection: string, rkey: string): string {
208 return `at://${did}/${collection}/${rkey}`;
209}
210
211export function generateCid(): string {
212 // Simple CID generation (in production, use proper IPLD/DAG-CBOR)
213 return `baf${Math.random().toString(36).substring(2, 15)}`;
6
7// Initialize database schema
8export async function initializeDatabase() {
9 // Create checkins table (v2 - lexicon compliant)
10 await sqlite.execute(`
Simple functional CSS library for Val Town
A helper function to build a file's email
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.