A simple, zero-configuration script to quickly boot FreeBSD ISO images using QEMU
1import { Database as Sqlite } from "@db/sqlite";
2import { DenoSqlite3Dialect } from "@soapbox/kysely-deno-sqlite";
3import { Kysely } from "kysely";
4import { CONFIG_DIR } from "./constants.ts";
5import type { STATUS } from "./types.ts";
6
7export const createDb = (location: string): Database => {
8 Deno.mkdirSync(CONFIG_DIR, { recursive: true });
9 return new Kysely<DatabaseSchema>({
10 dialect: new DenoSqlite3Dialect({
11 database: new Sqlite(location),
12 }),
13 });
14};
15
16export type DatabaseSchema = {
17 virtual_machines: VirtualMachine;
18 images: Image;
19 volumes: Volume;
20};
21
22export type VirtualMachine = {
23 id: string;
24 name: string;
25 bridge?: string;
26 macAddress: string;
27 memory: string;
28 cpus: number;
29 cpu: string;
30 diskSize: string;
31 drivePath?: string;
32 diskFormat: string;
33 isoPath?: string;
34 portForward?: string;
35 version: string;
36 status: STATUS;
37 pid: number;
38 volume?: string;
39 createdAt?: string;
40 updatedAt?: string;
41};
42
43export type Image = {
44 id: string;
45 repository: string;
46 tag: string;
47 size: number;
48 path: string;
49 format: string;
50 digest?: string;
51 createdAt?: string;
52};
53
54export type Volume = {
55 id: string;
56 name: string;
57 baseImageId: string;
58 path: string;
59 size?: string;
60 createdAt?: string;
61};
62
63export type Database = Kysely<DatabaseSchema>;