-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
52 lines (41 loc) · 1.76 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
48
49
50
51
52
const express = require('express');
const mongoose = require('mongoose');
const fileupload = require('express-fileupload')
const methodOverride = require('method-override')
const ejs = require("ejs")
const path = require("path");
const fs = require('fs');
const pageController = require('./controllers/pageController');
const kaynakController = require('./controllers/kaynakController');
const talepController = require('./controllers/talepController');
const ticketController = require('./controllers/ticketController')
const kullaniciController = require('./controllers/kullaniciController')
const app = express();
//Connect DB
// mongoose.connect('mongodb://127.0.0.1/hik-test-db');
mongoose.connect('mongodb+srv://beykent:[email protected]/');
//Template Engine
app.set("view engine","ejs");
//MIDDLEWARES
app.use(express.static("public"));
app.use(fileupload());
app.use(methodOverride('_method',{
methods: ['POST','GET']
})) // Put ve DELETE desteklemeyen sunucularda POST'un ikisini simule etmesi için
//--post ile gönderilen verileri yakalamak için aşağıdaki iki middleware'i kullanıyoruz
app.use(express.urlencoded({extended:true}))
app.use(express.json())
//ROUTES
app.get('/',kaynakController.getAllKaynakIndex);
app.get('/kaynakArama',kaynakController.getAllKaynak);
app.get('/kaynakTalebi', pageController.getKaynakTalebiPage);
app.get('/yardim', pageController.getYardimPage);
app.get('/profil', pageController.getProfilPage);
app.post('/', kullaniciController.kullaniciKayıtGiris);
app.post('/kaynakTalep', talepController.addKaynakTalep)
app.post('/ticket',ticketController.addTicket)
app.post('/profil', kullaniciController.profilDuzenle)
const port = 3000;
app.listen(port, () => {
console.log(`Server ${port} portunda calistirildi.`);
});