This commit is contained in:
Patryk Koreń
2026-07-02 23:55:40 +02:00
parent 04e34d15b5
commit e7ec832f5b
53 changed files with 9985 additions and 17 deletions

32
back/src/server.ts Normal file
View 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}`);
});