8
9// Server-side only code
10export default async function server(request: Request): Promise<Response> {
11 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
12 const SCHEMA_VERSION = 1
37// });
38
39function parseResultSet<T>(row: ResultSet): T[] {
40 return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
41}
51};
52
53function diffCircles(array1: Circle[], array2: Circle[]): Circle[] {
54 const changes: Circle[] = [];
55
74
75 const drag = (() => {
76 function dragstarted() {
77 d3.select(this).attr("stroke", "black");
78 }
79
80 function dragged(event, d) {
81 d3.select(this).raise().attr("cx", d.x = event.x).attr("cy", d.y = event.y);
82 }
83
84 function dragended() {
85 const x = d3.select(this).attr("cx");
86 const y = d3.select(this).attr("cy");
105 .call(drag)
106 .on("click", clicked);
107 function clicked(event, d) {
108 if (event.defaultPrevented) return; // dragged
109
10import { createRoot } from "https://esm.sh/react-dom/client";
11
12function App() {
13 const [image, setImage] = useState(null);
14 const [text, setText] = useState("Enter text here");
178}
179
180function client() {
181 createRoot(document.getElementById("root")).render(<App />);
182}
186}
187
188async function server(request: Request): Promise<Response> {
189 return new Response(`
190 <html>
1import Anthropic from "npm:@anthropic-ai/sdk@0.24.3";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {
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({
80</html>`;
81
82export function redirect(location: string): Response {
83 return new Response(null, {
84 headers: {
98const cookieName = "auth_session";
99
100export function passwordAuth(next, options?: PasswordAuthOptions) {
101 const sessionTable = options?.sessionTable || "password_auth_session";
102 return async (req: Request) => {
1export default async function handler(req: Request): Promise<Response> {
2 const resumeDetails = {
3 "basics": {
129 "highlights": [
130 "Developed a straightforward request lifecycle, handling both static and dynamic content efficiently",
131 "Implemented a flexible plugin system, enhancing extensibility and allowing for custom functionality in generated websites",
132 "Implemented efficient caching techniques, including in-memory content caching and static file path caching, to boost performance",
133 "Designed a flexible content source system, allowing for intuitive content organization based on directory structure",
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [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!)
36- [x] add listener for cmd+enter to submit query
4import { resumeConfig } from "https://esm.town/v/siygle/resumeConfig";
5
6export default async function resumeHandler(req: Request): Promise<Response> {
7 if (req.method === "GET") {
8 try {
48```
49
50You can allow anyone to signup by returning a boolean from the verifyEmail function:
51
52```ts
4import { deleteCookie, getCookies, setCookie } from "jsr:@std/http/cookie";
5
6async function createSession(email: string, hostname: string) {
7 const sessionID = crypto.randomUUID();
8 const expiresAt = new Date();
24}
25
26async function getSession(sessionID: string, hostname: string) {
27 try {
28 const res = await sqlite.execute({
50}
51
52async function deleteSession(sessionID: string) {
53 await sqlite.execute({
54 sql: `DELETE FROM lastlogin_session WHERE sessionID=?`,
65};
66
67export function lastlogin(
68 handler: (req: Request) => Response | Promise<Response>,
69 options: LastLoginOptions,