Back

Version 1

1/9/2025
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";

// Utility for generating unique IDs
const generateId = () => Math.random().toString(36).substring(2, 15);

// Simple password hashing (for demonstration - use proper hashing in production)
function hashPassword(password: string): string {
let hash = 0;
for (let i = 0; i < password.length; i++) {
const char = password.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash; // Convert to 32-bit integer
}
return Math.abs(hash).toString();
}

// Rest of the existing frontend code remains the same...

export default async function server(request: Request): Promise<Response> {
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
const KEY = new URL(import.meta.url).pathname.split("/").at(-1);
const SCHEMA_VERSION = 4; // Increment to reset database

// Create necessary tables
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS ${KEY}_users_${SCHEMA_VERSION} (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
role TEXT NOT NULL,
skills TEXT
)
`);
erhardik-usefulgreenpenguin.web.val.run
Updated: January 9, 2025