aboutsummaryrefslogtreecommitdiffstats
path: root/backend/ts/index.ts
diff options
context:
space:
mode:
authorMaks Jopek <maksymilian.jopek@prym-soft.pl>2021-04-04 01:53:24 +0200
committerMaks Jopek <maksymilian.jopek@prym-soft.pl>2021-04-04 01:53:24 +0200
commit292257d627bd1dfeafd772ac6457e2f54c2b73ba (patch)
treeb7962648b87ab709e8529075ce912950019adaee /backend/ts/index.ts
parenteee4ee32dd667ed6efd31ddcf8f64217b7e16b60 (diff)
downloadfia-292257d627bd1dfeafd772ac6457e2f54c2b73ba.tar.gz
fia-292257d627bd1dfeafd772ac6457e2f54c2b73ba.tar.zst
fia-292257d627bd1dfeafd772ac6457e2f54c2b73ba.zip
One step closer to the end
Diffstat (limited to 'backend/ts/index.ts')
-rw-r--r--backend/ts/index.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/backend/ts/index.ts b/backend/ts/index.ts
new file mode 100644
index 0000000..fd8f8e1
--- /dev/null
+++ b/backend/ts/index.ts
@@ -0,0 +1,22 @@
+import express from "express";
+import login from "./api/login";
+import session from "express-session";
+import * as dotenv from "dotenv";
+
+dotenv.config();
+const app = express();
+const PORT = 8000;
+
+if (!process.env.SESSION_KEY)
+ throw Error("SESSION_KEY is undefined");
+
+app.use(session({ secret: process.env.SESSION_KEY, cookie: { maxAge: 60000 } }))
+app.use("/", express.static("./public"));
+
+app.get("/favicon.ico", (req, res) => res.redirect("https://lukesmith.xyz/favicon.ico"));
+app.get("/blank", (req, res) => res.send(""));
+app.post("/login", (req, res, next) => login(req, res));
+
+app.listen(PORT, () => {
+ console.log(`[server]: Server is running at https://localhost:${PORT}`);
+});