#!/usr/bin/env -S deno run -A --watch=static/,routes/

import { connectDB } from "./src/user/db.ts";
import * as users from "./src/user/user.ts";

import dev from "$fresh/dev.ts";
await devUserAdd();
await dev(import.meta.url, "./main.ts");

async function devUserAdd() {
  if (Deno.env.get("DB_PATH") === ":memory:") {
    const db = await connectDB();
    const username = "admin";
    const password = "admin";
    const new_user = await users.createUser(username, password);
    await users.addUser(db, new_user);
  }
}
