✨ Add timetable, substitutions and history API
This commit is contained in:
@ -1,15 +1,19 @@
|
||||
import express from "express";
|
||||
import Prisma from "@prisma/client";
|
||||
import { getTimetable, getSubstitutions, getHistory } from "./api/index.js";
|
||||
|
||||
const app = express();
|
||||
const prisma = new Prisma.PrismaClient();
|
||||
const port = process.send.PORT || 3000;
|
||||
|
||||
app.get("/", async (_req, res) => {
|
||||
const result = await prisma.substitution.findMany();
|
||||
res.send(result);
|
||||
app.get("/api/timetable", getTimetable);
|
||||
app.get("/api/substitutions", getSubstitutions);
|
||||
app.get("/api/history", getHistory);
|
||||
app.get("/api/*", (req, res) => {
|
||||
res.sendStatus(400);
|
||||
});
|
||||
|
||||
app.use("/", express.static("../dist"));
|
||||
app.use("/*", express.static("../dist"));
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server listening on http://localhost:${port}`);
|
||||
});
|
||||
|
Reference in New Issue
Block a user