-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (45 loc) · 1.19 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
49
50
51
52
53
54
import express from "express";
import cors from "cors";
import dotenv from "dotenv";
import session from "express-session";
import { MemoryStore } from "express-session";
dotenv.config();
const app = express();
const PORT = process.env.PORT;
app.use(
cors({
origin: "http://localhost:3000",
credentials: true,
}),
);
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// session
app.use(
session({
cookie: {
maxAge: 900000,
secure: false,
sameSite: true,
},
secret: "halogays",
resave: false,
saveUninitialized: true,
store: new MemoryStore(),
}),
);
app.get("/", (_, res) => {
res.send("Hello, World!");
});
// Routes
import produk from "./src/routes/ProdukRoute.js";
import pelanggan from "./src/routes/PelangganRoute.js";
import detail from "./src/routes/PenjualanRoute.js";
import auth from "./src/routes/AuthRoute.js";
import pemasok from "./src/routes/PemasokRoute.js";
import pembelian from "./src/routes/Pembelian.js";
const routes = [produk, pelanggan, detail, auth, pemasok, pembelian];
routes.forEach((route) => {
app.use(route);
});
app.listen(PORT, () => console.log(`Server running in localhost:${PORT}`));