-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
47 lines (37 loc) · 1.24 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
require("dotenv").config();
require("express-async-errors");
const express = require("express");
const app = express();
const connectDb = require("./db/connectDb");
const firebaseApp = require("firebase/app");
const errorHandeller = require("./middlewares/error-handeller");
const cookie = require("cookie-parser");
const paypal = require("paypal-rest-sdk");
const cors = require("cors");
// routers
const authRoute = require("./routes/auth");
const productRoute = require("./routes/products");
app.use(express.json());
app.use(cors({ origin: "*" }));
app.use(express.urlencoded({ extended: true }));
app.use(cookie());
paypal.configure({
mode: "sandbox", //sandbox or live
client_id: process.env.CLIENT_ID,
client_secret: process.env.CLIENT_SECRET,
});
firebaseApp.initializeApp(require("./firebase/config"));
app.use("/api/v1/auth", authRoute);
app.use(require("./middlewares/authorization"));
app.use("/api/v1/product", productRoute);
app.post("/api/v1/contact", require("./controllers/contact"));
// error handeller
app.use(errorHandeller);
const port = process.env.PORT || 8080;
const start = async () => {
await connectDb(process.env.MONGO_URL);
app.listen(port, () => {
console.log(`server is listening to port ${port}`);
});
};
start();