forked from AVVKavvk/Social-Media-Server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
46 lines (43 loc) · 1.17 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 dbconnect = require("./Dbconnect");
const dotenv = require("dotenv");
dotenv.config("./.env");
const express = require("express");
const authRouter = require("./routers/authRouter");
const postRouter = require("./routers/postRouter");
const userRouter = require("./routers/userRouter");
const app = express();
const cookie = require("cookie-parser");
const morgan = require("morgan");
const cors = require("cors");
const cloudinary = require("cloudinary").v2;
// Configuration
cloudinary.config({
cloud_name: process.env.Cloudinary_Cloud_Name,
api_key: process.env.Cloudinary_API_Key,
api_secret: process.env.Cloudinary_API_Secret,
});
app.use(morgan("common"));
app.use(express.json({ limit: "10mb" }));
app.use(cookie());
// app.use(cors());
let origin="https://socialclient.onrender.com/"
app.use(
cors({
credentials: true,
origin
})
);
// app.use(cors({
// credentials: true,
// }))
app.use("/auth", authRouter);
app.use("/post", postRouter);
app.use("/user", userRouter);
app.get("/", (req, res) => {
res.send("connected");
});
dbconnect();
const port = process.env.port ||3003;
app.listen(port, (req, res) => {
console.log(`server started on port ${port}`);
});