aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/ts/api/login.ts19
-rw-r--r--src/backend/ts/index.ts15
-rw-r--r--src/backend/tsconfig.json9
-rw-r--r--src/frontend/ts/login.ts12
-rw-r--r--src/frontend/tsconfig.json12
5 files changed, 67 insertions, 0 deletions
diff --git a/src/backend/ts/api/login.ts b/src/backend/ts/api/login.ts
new file mode 100644
index 0000000..045f408
--- /dev/null
+++ b/src/backend/ts/api/login.ts
@@ -0,0 +1,19 @@
+"use strict";
+import { Request, Response } from 'express';
+import fetch from "node-fetch";
+export default async function apiLogin(req: Request, res: Response) {
+ let response = await fetch("https://jopek.eu/maks/szkola/apkKli/fiaFiles/fia.php", {
+ method: "POST",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ apiKey: process.env.API_KEY,
+ stmt: "SELECT `data` FROM `fia` WHERE `started`= ?",
+ params: [false]
+ }),
+ });
+ let resText = await response.text()
+ res.send(resText);
+} \ No newline at end of file
diff --git a/src/backend/ts/index.ts b/src/backend/ts/index.ts
new file mode 100644
index 0000000..a6dab5b
--- /dev/null
+++ b/src/backend/ts/index.ts
@@ -0,0 +1,15 @@
+import express from 'express';
+import login from './api/login';
+import * as dotenv from 'dotenv';
+
+dotenv.config();
+const app = express();
+const PORT = 8000;
+
+app.use("/", express.static("./public"));
+
+app.get('/login', (req, res) => login(req, res));
+
+app.listen(PORT, () => {
+ console.log(`[server]: Server is running at https://localhost:${PORT}`);
+}); \ No newline at end of file
diff --git a/src/backend/tsconfig.json b/src/backend/tsconfig.json
new file mode 100644
index 0000000..760fd4c
--- /dev/null
+++ b/src/backend/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "../../tsconfig.json",
+ "include": [
+ "ts/**/*"
+ ],
+ "compilerOptions": {
+ "outDir": "./js"
+ }
+} \ No newline at end of file
diff --git a/src/frontend/ts/login.ts b/src/frontend/ts/login.ts
new file mode 100644
index 0000000..6ff53cd
--- /dev/null
+++ b/src/frontend/ts/login.ts
@@ -0,0 +1,12 @@
+let html = /* html */`
+ <div class="container text-center fs-1" style="margin-top: 45vh;">
+ <label for="username">Vad heter du?</label>
+ <input type="text" name="username" required>
+ <button type="button" class="btn btn-light btn-lg" onclick="login">Starta spelet</button>
+ </div>
+`;
+document.body.innerHTML = html;
+
+function login() {
+
+} \ No newline at end of file
diff --git a/src/frontend/tsconfig.json b/src/frontend/tsconfig.json
new file mode 100644
index 0000000..b0975f3
--- /dev/null
+++ b/src/frontend/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "lib": [
+ "DOM"
+ ],
+ "outDir": "../../public/js"
+ },
+ "include": [
+ "ts/**/*"
+ ]
+} \ No newline at end of file