summaryrefslogtreecommitdiff
path: root/app/app.js
diff options
context:
space:
mode:
authorAlexis Hovorka <[email protected]>2024-02-17 00:42:20 -0700
committerAlexis Hovorka <[email protected]>2024-02-17 00:42:20 -0700
commit8f44593d55c82197854d9e29174fe66c4e50ebde (patch)
treea43a6d763517d1304076897952b1111886303158 /app/app.js
parentc5aa364e0e372d0e29063a27bd17811446db8b6a (diff)
[refactor] Switch to ES Modules
Diffstat (limited to 'app/app.js')
-rw-r--r--app/app.js31
1 files changed, 14 insertions, 17 deletions
diff --git a/app/app.js b/app/app.js
index 23bf0ab..b4af44b 100644
--- a/app/app.js
+++ b/app/app.js
@@ -1,18 +1,18 @@
-"use strict";
+import fs from "node:fs";
+import http from "node:http";
+import crypto from "node:crypto";
+import {sj, cors} from "./utils.js";
-const fs = require("fs");
-const http = require("http");
-const crypto = require("crypto");
-const {sj, cors} = require("./utils");
+import Router from "./lib/router.js";
+import Static from "./lib/static.js";
+//import Socket from "./lib/Socket.js";
+//import pipe from "./lib/pipe.js";
+//import otp from "./lib/otp.js";
-const Router = require("./lib/router");
-const Static = require("./lib/static");
-//const Socket = require("./lib/socket");
-//const pipe = require("./lib/pipe");
-//const otp = require("./lib/otp");
+import {HOST, PORT} from "./config.js";
-const config = require("./config");
-const {HOST, PORT} = config;
+import * as auth from "./auth.js";
+import * as noteStore from "./note-store.js";
if (!fs.existsSync("./logs")) fs.mkdirSync("./logs");
if (!fs.existsSync("./users")) fs.mkdirSync("./users");
@@ -23,13 +23,10 @@ const stat = new Static("./public");
//const wss = new Socket(server);
const app = new Router();
-const auth = require("./auth")(config);
-const authed = auth.authed;
auth.attach(app);
+noteStore.attach(app);
-const noteStore = require("./note-store");
-noteStore.attach(app, auth);
-
+const authed = auth.authed;
app.get("/user", authed((req, res) => {
console.log(Date.now()+" Getting user data for "+req.uid);
sj(res, {uid: req.uid, username: auth.getUsername(req.uid)});