✨ Add basic auth functionality
This commit is contained in:
@ -5,12 +5,18 @@ import {
|
||||
getHistory,
|
||||
getClasses,
|
||||
} from "./api/index.js";
|
||||
import { Auth } from "./api/auth.js";
|
||||
import { Parser } from "./parser/index.js";
|
||||
import cors from "cors";
|
||||
import cookieParser from "cookie-parser";
|
||||
|
||||
const app = express();
|
||||
const port = process.env.PORT || 3000;
|
||||
app.use(cors());
|
||||
app.use(cookieParser());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
const auth = new Auth();
|
||||
|
||||
if (!process.env.DSB_USER || !process.env.DSB_PASSWORD) {
|
||||
console.error("Error: DSB Auth environment variables missing!");
|
||||
@ -22,6 +28,9 @@ const parser = new Parser(
|
||||
process.env.UPDATE_INTERVAL || 1 * 60 * 1000
|
||||
);
|
||||
|
||||
app.post("/login", auth.login);
|
||||
app.use(auth.checkLogin);
|
||||
|
||||
app.get("/api/timetable", getTimetable);
|
||||
app.get("/api/substitutions", getSubstitutions);
|
||||
app.get("/api/history", getHistory);
|
||||
|
Reference in New Issue
Block a user