-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
23 lines (19 loc) · 697 Bytes
/
server.js
File metadata and controls
23 lines (19 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import express from "express";
import path from "path";
import { fileURLToPath } from "url";
import userrouter from "./routes/user.routes.js";
import urlrouter from "./routes/url.routes.js";
import { authenticationMiddleware } from "./middleware/auth.middleware.js";
const app = express();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const publicDir = path.join(__dirname, "public");
app.use(express.json());
app.use(authenticationMiddleware);
app.use(express.static(publicDir));
app.use("/user", userrouter);
app.use(urlrouter);
app.get("/", (req, res) => {
return res.sendFile(path.join(publicDir, "index.html"));
});
export default app;