ldap
This commit is contained in:
32
back/src/server.ts
Normal file
32
back/src/server.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
// src/server.ts
|
||||
import express from "express";
|
||||
import dotenv from "dotenv";
|
||||
import authRoutes from "./routes/auth";
|
||||
import protectedRoutes from "./routes/protected";
|
||||
import cors from "cors";
|
||||
import { authMiddleware } from "./middleware/auth";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(cors({
|
||||
origin: "http://localhost:5173",
|
||||
methods: ["GET", "POST"],
|
||||
credentials: true
|
||||
}));
|
||||
|
||||
app.use(express.json());
|
||||
|
||||
app.use("/auth", authRoutes);
|
||||
app.use("/protected", authMiddleware, protectedRoutes);
|
||||
|
||||
app.get("/health", (_, res) => {
|
||||
res.json({ status: "ok" });
|
||||
});
|
||||
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server running on http://localhost:${PORT}`);
|
||||
});
|
||||
Reference in New Issue
Block a user