forked from AniketIndulkar/URLShortner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
23 lines (18 loc) 路 697 Bytes
/
Copy pathapp.js
File metadata and controls
23 lines (18 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
require("dotenv").config();
const express = require("express");
const path = require("path");
const app = express();
app.use(express.json());
// 馃憠 Serve static frontend from the "public" folder
app.use(express.static(path.join(__dirname, "public")));
// 馃憠 API routes
const shortenRoute = require("./routes/shorten");
const redirectRoute = require("./routes/redirect");
const analyticsRoute = require("./routes/analytics");
app.use("/shorten", shortenRoute);
app.use("/", analyticsRoute);
app.use("/", redirectRoute); // This should stay last
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`URL Shortener service running on http://localhost:${PORT}`);
});