diff options
-rw-r--r-- | .gitmodules | 4 | ||||
-rwxr-xr-x | run | 3 | ||||
m--------- | src/abc | 0 | ||||
-rw-r--r-- | src/db/DBController.ts | 16 | ||||
-rw-r--r-- | src/db/user.ts | 3 | ||||
-rw-r--r-- | src/groups/user.ts | 5 | ||||
-rw-r--r-- | src/handler/user.ts | 3 | ||||
-rw-r--r-- | src/main.ts | 6 | ||||
-rw-r--r-- | test/database_test.ts | 7 |
9 files changed, 34 insertions, 13 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c9abcd5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "src/abc"] + path = src/abc + url = git@github.com:LarsVomMars/abc.git + branch = std @@ -1,3 +1,4 @@ #!/usr/bin/env sh -deno run -q --allow-net --allow-env --allow-read --unstable src/main.ts +deno test test/ && + deno run -q --allow-net --allow-env --allow-read --unstable src/main.ts diff --git a/src/abc b/src/abc new file mode 160000 +Subproject adba5f857e1f2a53bfffba1aa184c6d2ca5c48e diff --git a/src/db/DBController.ts b/src/db/DBController.ts index 2cfd1f2..c01d7b4 100644 --- a/src/db/DBController.ts +++ b/src/db/DBController.ts @@ -34,10 +34,10 @@ export default class DBController { } } - async execute(query: string) { + async execute(query: string, params?: string[]) { if (this.client) { try { - return await this.client.execute(query); + return await this.client.execute(query, params); } catch (e) { throw e; } @@ -45,11 +45,15 @@ export default class DBController { } async execute_multiple(queries: string[]) { - await this.client!.transaction(async (conn) => { - queries.forEach(async (query) => { - await conn.execute(query); + try { + return await this.client!.transaction(async (conn) => { + queries.forEach(async (query) => { + await conn.execute(query); + }); }); - }); + } catch (e) { + throw e; + } } async close() { diff --git a/src/db/user.ts b/src/db/user.ts index c245b5f..1e20564 100644 --- a/src/db/user.ts +++ b/src/db/user.ts @@ -1,6 +1,7 @@ import DBController from "./DBController.ts"; -class User extends DBController { +class User { + createUser() {} } export default new User(); diff --git a/src/groups/user.ts b/src/groups/user.ts index ae6d2ad..59cda82 100644 --- a/src/groups/user.ts +++ b/src/groups/user.ts @@ -1,6 +1,7 @@ -import type { Group, Context } from "https://deno.land/x/abc@v1/mod.ts"; +// import type { Group, Context } from "https://deno.land/x/abc@v1/mod.ts"; +import type { Group, Context } from "../abc/mod.ts"; import * as handlers from "../handler/user.ts"; export default function (g: Group) { - g.get("/:name", handlers.index); + g.get("/:name", handlers.index); } diff --git a/src/handler/user.ts b/src/handler/user.ts index 33b96a2..78db609 100644 --- a/src/handler/user.ts +++ b/src/handler/user.ts @@ -1,4 +1,5 @@ -import type { HandlerFunc, Context } from "https://deno.land/x/abc@v1/mod.ts"; +// import type { HandlerFunc, Context } from "https://deno.land/x/abc@v1/mod.ts"; +import type { HandlerFunc, Context } from "../abc/mod.ts"; import db from "../db/user.ts"; export const index: HandlerFunc = async (c: Context) => c.params.name; diff --git a/src/main.ts b/src/main.ts index 3eded62..9b16126 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,8 @@ import "https://deno.land/x/dotenv/load.ts"; -import { Application } from "https://deno.land/x/abc@v1/mod.ts"; -import type { Context } from "https://deno.land/x/abc@v1/mod.ts"; +// import { Application } from "https://deno.land/x/abc@v1/mod.ts"; +// import type { Context } from "https://deno.land/x/abc@v1/mod.ts"; +import { Application } from "./abc/mod.ts"; +import type { Context } from "./abc/mod.ts"; import { renderFile } from "https://deno.land/x/dejs/mod.ts"; import * as groups from "./groups/index.ts"; import DBController from "./db/DBController.ts"; diff --git a/test/database_test.ts b/test/database_test.ts new file mode 100644 index 0000000..ca2e5b0 --- /dev/null +++ b/test/database_test.ts @@ -0,0 +1,7 @@ +import { assertEquals, assertArrayContains } from "https://deno.land/std/testing/asserts.ts"; + +Deno.test("hello world", () => { + const x = 1 + 2; + assertEquals(x, 3); + assertArrayContains([1, 2, 3, 4, 5, 6], [3], "Expected 3 to be in the array"); +}); |