-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (41 loc) · 1.07 KB
/
index.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const express = require("express");
const path = require("path");
const app = express();
const port = process.env.PORT || 3000;
// Serve static files (HTML, CSS, JS)
app.use(express.static(path.join(__dirname)));
// API endpoint for ads
app.get("/api/ads", (req, res) => {
res.json({
ad: {
message: "Discover rare NFTs on Marketplace Y!",
link: "https://example.com"
}
});
});
// API endpoint for authentication (auth.js equivalent)
app.get("/api/auth", (req, res) => {
res.json({
message: "User authenticated!"
});
});
// API endpoint for clicks (click.js equivalent)
app.get("/api/click", (req, res) => {
res.json({
message: "Ad click recorded!"
});
});
// API endpoint for payments (payments.js equivalent)
app.get("/api/payments", (req, res) => {
res.json({
message: "Payment processed!"
});
});
// Fallback to serve index.html for unknown routes
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "index.html"));
});
// Start the server
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});