-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
60 lines (56 loc) · 1.57 KB
/
app.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
49
50
51
52
53
54
55
56
57
58
59
60
import AppUserRouter from "./api/AppUserRouter.js";
import BidRouter from "./api/BidRouter.js";
import ProductRouter from "./api/ProductRouter.js";
import TransactionRouter from "./api/TransactionRouter.js";
import AdressRouter from "./api/AddressRouter.js";
import express from "express";
import cors from "cors";
import cookieSession from "cookie-session";
import dotenv from "dotenv";
import bodyParser from "body-parser";
import axios from "axios";
dotenv.config();
const PORT = 5000;
const app = express();
app.use(express.static("public"));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// app.use(express.json());
app.use(
cookieSession({
signed: false,
secure: false,
sameSite: "lax",
})
);
app.use(
cors({
origin: "http://localhost:3000",
credentials: true,
})
);
app.use("/api", AppUserRouter);
app.use("/api/bids", BidRouter);
app.use("/api/products", ProductRouter);
app.use("/api/transactions", TransactionRouter);
app.use("/api/addresses", AdressRouter);
const checkProductStatus = async () => {
axios
.get("http://localhost:5000/api/products/status")
.then((res) => {
console.log("Product status monitoring started.");
})
.catch((err) => {
console.log(err);
});
};
// setInterval(checkProductStatus, 1 * 2 * 1000);
// Define your routes and middleware here
app.get("/", (req, res) => {
res.json({ message: "Hello World!" });
});
app.listen(PORT || 5000, () => {
console.log("JWT_SECRET :", process.env.JWT_SECRET);
console.log(`Server is running on http://localhost:${PORT}`);
});
//