-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (32 loc) · 929 Bytes
/
server.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
const express = require("express");
const dotenv = require("dotenv");
const connectDB = require("./connectDB");
const path=require("path");
const cors = require("cors");
const routers = require("./routers");
// Environment Variables
dotenv.config({
path: "./config/env/config.env"
});
// MONGODB Connection
connectDB();
//localhost:5000/api/question
//localhost:5000/api/auth
const app = express();//Express Yükleme
// Express-Body Middleware
app.use(express.json())
const PORT = process.env.PORT;
app.use(cors());
// app.use(cookieParser())
//ROUTERS MİDDLEWARE
// app.use("/api/questions",question);
// app.use("/api/auth",auth);
// app.use("/api/answers",auth);
//-------Bunların Yerine---->
app.use("/api", routers);
//Static File
// console.log(__dirname);
app.use(express.static(path.join(__dirname,"public")));
app.listen(PORT, () => {
console.log(`App Started on ${PORT}: ${process.env.NODE_ENV}`);
});