-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
43 lines (35 loc) · 1.13 KB
/
Copy pathserver.js
File metadata and controls
43 lines (35 loc) · 1.13 KB
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
require("dotenv").config();
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const mongoose = require("mongoose");
const authRoute = require("./routes/auth/authRoute");
const server = express();
server.use(bodyParser.json({ limit: "30mb", extended: 30 }));
server.use(bodyParser.urlencoded({ limit: "30mb", extended: 30 }));
server.use(cors());
const PORT = process.env.PORT;
const MONGO_CONN_STR = process.env.MONGO_CONN_STR;
console.log("MONGO_CONN_STR: ", MONGO_CONN_STR);
server.get("/", (req, res) => {
res.send("sa");
});
server.use("/auth", authRoute);
const conn = mongoose
.connect(MONGO_CONN_STR, {
useNewUrlParser: true,
useFindAndModify: false,
useCreateIndex: true,
useUnifiedTopology: true,
})
.then(() => {
server.listen(PORT, () => {
// const Cat = mongoose.model("Cat", { name: String });
// const kitty = new Cat({ name: "Zildjian" });
// kitty.save().then(() => console.log("meow"));
console.log("Server Çalıştı");
});
})
.catch((err) => {
console.log("bir sorunla karşılaşıldı", err);
});