27- [ ] add visible output for non-query statements
28- [ ] add schema viewing
29- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
30- [ ] add refresh to table list sidebar after `CREATE/DROP/ALTER` statements
31- [ ] add automatic execution of initial select query on double click
1export default async function(req: Request): Promise<Response> {
2 return Response.json({ name: "iasjdlkasj" });
3}
11};
12
13async function createSessionTable(tableName: string) {
14 await sqlite.execute(`CREATE TABLE ${tableName} (
15 id TEXT NOT NULL PRIMARY KEY,
19}
20
21async function createSession(tableName: string, valSlug: string): Promise<Session> {
22 try {
23 const expires_at = new Date();
39}
40
41async function getSession(tableName: string, sessionID: string, valSlug: string): Promise<Session> {
42 try {
43 const { rows, columns } = await sqlite.execute({
60}
61
62async function fetchUser(token: string): Promise<{ id: string }> {
63 const resp = await fetch("https://api.val.town/v1/me", {
64 headers: {
74}
75
76async function verifyApiToken(token: string) {
77 try {
78 const [currentUser, requestUser] = await Promise.all([fetchUser(Deno.env.get("valtown")), fetchUser(token)]);
105</html>`;
106
107export function redirect(location: string): Response {
108 return new Response(null, {
109 headers: {
123const cookieName = "auth_session";
124
125export function passwordAuth(next, options?: PasswordAuthOptions) {
126 let passwords: string[];
127 if (!options?.password) {
4
5// @see: https://developer.apple.com/documentation/corefoundation/1542812-cfdategetabsolutetime#discussion
6export function toDate(cocoaTimestamp: number) {
7 return new Date(COCOA_REF_DATE.getTime() + cocoaTimestamp * 1000);
8}
3const GOOGLE_FAVICONS_BASE_URL = "https://www.google.com/s2/favicons";
4
5export function createFaviconURL(url: string | URL, size = 16): URL {
6 const { hostname } = new URL(url);
7 const faviconURL = new URL(GOOGLE_FAVICONS_BASE_URL);
8const hello = Deno.env.get("HELLO_WORLD");
9
10export async function MyFooter(logo = valTownLogoAuto) {
11 const recommendation = rootValRef().handle === USERNAME
12 ? html`<span class="recommends">${await recommends()}</span>`
36}
37
38export default async function(req) {
39 const { Layout } = await import("https://esm.town/v/postpostscript/Layout");
40 return htmlResponse`${Layout`
1// SPDX-License-Identifier: 0BSD
2
3export function extractHeaderComments(code: string) {
4 const comments: string[] = [];
5
6const isConjuction = (info: Info): info is ConjunctionInfo => "conjuction" in info;
7
8export function parseLicenseInfo(code: string) {
9 const comments = extractHeaderComments(code);
10 const pragma = comments
16}
17
18export function formatLicenseInfo(info: Info, level = 0) {
19 if (!isConjuction(info)) {
20 let output = info.license;
3import { gfm as gfmMarkdown, gfmHtml } from "npm:micromark-extension-gfm";
4
5export function html(markdown: string) {
6 return micromark(markdown, {
7 extensions: [gfmMarkdown(), frontmatter()],
10}
11
12export async function gfm(markdown: string, options?: { title?: string; favicon?: string | URL }) {
13 const body = await html(markdown);
14 const faviconURL = new URL(options?.favicon ?? "📝", "https://fav.farm");
49};
50URL.revokeObjectURL(patchedModUrl);
51export default async function oldstyle(...args: Parameters<typeof String.raw>) {
52 const gen = tokens(String.raw(...args), { jsx: true });
53 const identifiers = new Set<string>();
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": "*",