-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (24 loc) · 855 Bytes
/
server.js
File metadata and controls
31 lines (24 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require("dotenv").config();
const express = require("express");
const cors = require("cors");
const path = require("path");
const authRoutes = require("./server/authRoutes");
const apiRoutes = require("./server/apiRoutes");
const app = express();
app.set("trust proxy", 1);
app.use(cors({ origin: true, credentials: true }));
app.use(express.json());
app.use(express.static(path.join(__dirname, "public")));
app.use("/auth", authRoutes);
app.use("/api", apiRoutes);
app.get(/.*/, (_req, res) =>
res.sendFile(path.join(__dirname, "public", "index.html"))
);
app.use((err, _req, res, _next) => {
console.error(err);
res.status(500).json({ error: "Sunucu hatası." });
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () =>
console.log(`🚀 Study Tracker → http://localhost:${PORT}`)
);