aboutsummaryrefslogtreecommitdiff
path: root/src/db/connector.ts
diff options
context:
space:
mode:
authorLarsVomMars2020-07-09 23:58:30 +0200
committerLarsVomMars2020-07-09 23:58:30 +0200
commite9aa61e7fb8c048afe96d000b7ba0cb7261791f1 (patch)
treec320802018dc05e48b986e761150218697091776 /src/db/connector.ts
parent5c6e6e9962187335d80ee8f31921ee561c430365 (diff)
Boilerplate, debugger, modules, ...
Diffstat (limited to 'src/db/connector.ts')
-rw-r--r--src/db/connector.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/db/connector.ts b/src/db/connector.ts
new file mode 100644
index 0000000..6b9bfec
--- /dev/null
+++ b/src/db/connector.ts
@@ -0,0 +1,17 @@
+import { Client } from "https://deno.land/x/mysql/mod.ts";
+
+export default class Connector {
+ async connect(): Promise<Client> {
+ try {
+ return await new Client().connect({
+ hostname: Deno.env.get("DBHost"),
+ username: Deno.env.get("DBUser"),
+ db: Deno.env.get("DBName"),
+ password: Deno.env.get("DBPassword"),
+ });
+ } catch (e) {
+ console.error("Could not connect to database!");
+ throw e;
+ }
+ }
+}