-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
36 lines (26 loc) · 840 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
// Proje 5 katmandan oluşacak
const express = require('express');
const dotenv = require('dotenv');
const routers = require('./routers');
const customErrorHandler = require('./middlewares/errors/customErrorHandler');
const connectDatabase = require('./helpers/database/connectDatabase');
const path = require('path');
// Environment Variables
dotenv.config({
path: "./config/env/config.env"
});
//MongoDb Connection
connectDatabase();
const app = express();
// Express - Body Middleware
app.use(express.json());
const PORT = process.env.PORT; // in case deployment
//Routers Middleware
app.use("/api", routers);
//Error Handler
app.use(customErrorHandler)
//Static Files
app.use(express.static(path.join(__dirname, "public")));
app.listen(PORT, () => {
console.log(`App started on ${PORT}: ${process.env.NODE_ENV}`);
});