Shortened database/utils.ts by adding a 'Query Database' helper function to reduce boilerplate/copied code, also added functions form apping the Post, Account and Comment row. api/main.ts now has more unfinished endpoints and will now work using functions instead of doing everything inside of the routes, created a helpers.ts file to make it a bit more modular and easier to look over.

This commit is contained in:
Esad Mustafoski
2024-11-13 23:29:59 +01:00
parent 7a6152be51
commit b0f8a51cc8
6 changed files with 298 additions and 245 deletions

View File

@@ -1,10 +1,10 @@
/// <reference lib="deno.ns" />
/**
* @author Esad Mustafoski
* @description This file is responsible for creating the database and the tables
*/
/// <reference lib="deno.ns" />
// +++ IMPORTS ------------------------------------------------------ //
import { DB } from "https://deno.land/x/sqlite/mod.ts";
import { dirname, fromFileUrl, join } from "https://deno.land/std/path/mod.ts";
@@ -50,9 +50,9 @@ export function createDatabase(): void {
likes INTEGER
)
`);
}
};
// Sample data generated using online generators
// Sample data generated using AI, does not work yet and will be adjusted
export function insertSampleData(): void {
db.query(`INSERT INTO accounts (user_group, user_bio, user_displayname, user_username, user_email, password, firstname, surname, account_created, followers, following, contacts) VALUES
('admin', 'Admin bio', 'Admin User', 'admin', 'admin@example.com', 'hashedpass1', 'Admin', 'User', '2024-01-01', '[]', '[]', '[]', '[]'),