aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig7
-rw-r--r--.gitignore4
-rw-r--r--.vscode/launch.json14
-rw-r--r--src/db/connector.ts17
-rw-r--r--src/handler/.gitkeep0
-rw-r--r--src/main.ts12
-rw-r--r--src/public/index.html10
-rw-r--r--src/router/.gitkeep0
8 files changed, 59 insertions, 5 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..fe1ae2d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,7 @@
+root = true
+
+[*.ts]
+end_of_line = lf
+insert_final_newline = true
+indent_style = space
+indent_size = 2
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2bc2509
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.idea/
+.vscode/*
+!.vscode/launch.json
+src/.env \ No newline at end of file
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..80b8701
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,14 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Deno",
+ "type": "node",
+ "request": "launch",
+ "cwd": "${workspaceFolder}/src/",
+ "runtimeExecutable": "deno",
+ "runtimeArgs": ["run", "--inspect", "-A", "${file}"],
+ "port": 9229
+ }
+ ]
+ } \ No newline at end of file
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;
+ }
+ }
+}
diff --git a/src/handler/.gitkeep b/src/handler/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/handler/.gitkeep
diff --git a/src/main.ts b/src/main.ts
index 29dc789..bcdb632 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,9 +1,11 @@
-import { Application } from "https://deno.land/x/abc@v1/mod.ts";
+import { Application, Context } from "https://deno.land/x/abc@v1/mod.ts";
+import "https://deno.land/x/dotenv/load.ts";
+const port = parseInt(Deno.env.get("PORT") || "8080");
const app = new Application();
-console.log("Started server!");
+app.static("/", "./src/public/"); // Manage static files
+app.file("/", "./src/public/index.html"); // Render index on /
-app.get("/", (c) => {
- return "Hello, world!";
-}).start({ port: 8080 });
+app.start({ port });
+console.log(`Server listening on http://localhost:${port}`);
diff --git a/src/public/index.html b/src/public/index.html
new file mode 100644
index 0000000..25eaea5
--- /dev/null
+++ b/src/public/index.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>Title</title>
+</head>
+<body>
+ <h1>Home :)</h1>
+</body>
+</html> \ No newline at end of file
diff --git a/src/router/.gitkeep b/src/router/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/router/.gitkeep