Added database creation upon start of API, only does this when the Database doesn't exist.

This commit is contained in:
Lynixenn
2025-03-28 23:51:03 +01:00
parent cfcfd4ba5e
commit 895a40fe67
3 changed files with 71 additions and 33 deletions

View File

@@ -12,6 +12,12 @@ import {
Router,
} from "https://deno.land/x/oak@v17.1.2/mod.ts";
import { oakCors } from "https://deno.land/x/cors@v1.2.2/mod.ts";
import {
dirname,
fromFileUrl,
join,
} from "https://deno.land/std@0.224.0/path/mod.ts";
import * as db_utils from "../database/utils.ts";
import * as helper_utils from "./helpers.ts";
@@ -48,6 +54,9 @@ type ApiResponse = {
body: unknown;
};
// database creation if missing, runs here because this is the main file executed by the API.
db_utils.ensureDatabaseExists();
// +++ ROUTER ------------------------------------------------------- //
// Creates the routes for the API server.
// Example: localhost:8000/api will show "testAPIPoint"