From 8f44593d55c82197854d9e29174fe66c4e50ebde Mon Sep 17 00:00:00 2001 From: Alexis Hovorka Date: Sat, 17 Feb 2024 00:42:20 -0700 Subject: [refactor] Switch to ES Modules --- app/app.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'app/app.js') 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)}); -- cgit v1.2.3-70-g09d2