forked from BiteSense/bitesense-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (38 loc) · 1.11 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
const env = require("dotenv");
env.config();
const express = require("express");
const db = require("./src/configs/db.configs");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser");
const multer = require("multer");
const port = process.env.PORT || 8080;
const userRoutes = require("./src/routes/user.routes.js");
const productRoutes = require("./src/routes/product.routes.js");
const qrcodeRoutes = require("./src/routes/qrcode.routes");
const app = express();
//Middle Multer File
const multerMid = multer({
storage: multer.memoryStorage(),
limits: {
fileSize: 5 * 1024 * 1024,
},
});
try {
//DB CONNECTION
db.authenticate();
console.log("connected");
} catch (error) {
console.log(error);
}
app.use(express.json());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(multerMid.single("file"));
// Handling route
app.use("/api/users", userRoutes);
app.use("/api/products", productRoutes);
app.use("/api/qrcode", qrcodeRoutes);
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});