mirror of
https://github.com/detleph/server.git
synced 2026-09-04 08:36:06 +02:00
37 lines
840 B
TypeScript
37 lines
840 B
TypeScript
import express from "express";
|
|
import prisma from "./lib/prisma";
|
|
import eventRouter from "./Routes/event.routes";
|
|
import adminAuthRouter from "./Routes/admin_auth.routes";
|
|
|
|
require("dotenv").config(); // Load dotenv config
|
|
|
|
const app = express();
|
|
|
|
async function main() {
|
|
// Todo: Everything
|
|
|
|
// Bodyparser and urlencoded to parse post request bodies
|
|
app.use(express.urlencoded({ extended: true }));
|
|
app.use(express.json());
|
|
|
|
// Admin authentication endpoints
|
|
app.use("/api/authentication", adminAuthRouter);
|
|
|
|
// All API endpoints are behind /api/...
|
|
app.use("/api/events", eventRouter);
|
|
|
|
app.listen(process.env.PORT, () => {
|
|
console.log(`Listening on Port: ${process.env.PORT}`);
|
|
});
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
throw e;
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|
|
|
|
export default app;
|