-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (38 loc) · 1.15 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
const express = require("express");
const authRouter = require("./Routes/admin/auth");
const adminproductsRouter = require("./Routes/admin/products");
const productsRouter = require('./Routes/products')
const cartsRouter = require('./Routes/carts');
const cookieSession = require("cookie-session");
const bodyParser = require("body-parser");
const app = express();
app.use(express.static("public")); //make everthing available in public folder to the outside world
app.use(bodyParser.urlencoded({ extended: true }));
app.use(
cookieSession({
keys: ["dsfgvbhgdfsadrfwfsedcqads324r4w"],
})
);
app.use(authRouter);
app.use(adminproductsRouter);
app.use(productsRouter);
app.use(cartsRouter);
//const bodyParser = (req, res, next) => {
// if (req.method == "POST") {
// req.on("data", (data) => {x
// const parsed = data.toString("utf8").split("&");
// const formData = {};
// for (const pair of parsed) {
// const [key, value] = pair.split("=");
// formData[key] = value;
// }
// req.body = formData;
// next();
// });
// } else {
// next();
// }
//};
app.listen(8080, () => {
console.log("Listening");
});