-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
69 lines (53 loc) · 1.41 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import express from 'express'
import pageRouter from './routes/pageRouter.js'
import photoRouter from './routes/photoRouter.js'
import userRouter from './routes/userRouter.js'
import cookieParser from 'cookie-parser'
import {checkUser} from './middlerwares/authMiddleware.js'
import methodOverride from 'method-override'
//bunu bilgisatrdan yyuklerken name ulasmasi icn
import fileUpload from 'express-fileupload'
//bunu depolamak icin kullaniriz
import {v2 as cloudinary} from 'cloudinary'
import dotenv from 'dotenv'
dotenv.config()
cloudinary.config({
cloud_name:process.env.CLOUD_NAME,
api_key:process.env.CLOUD_API_KEY,
api_secret:process.env.CLOUD_API_SECRET
})
import con from './db.js'
//
con()
const app =express()
const port = process.env.PORT;
//ejs
app.set('view engine','ejs')
app.use(express.json())
app.use(express.urlencoded({extended:true}))
app.use(cookieParser())
app.use(fileUpload({useTempFiles:true}))
//FOLOW UN FOLLOW
app.use(methodOverride('_method',{
methods:['POST','GET']
}))
app.use(express.static('public'))
//router
//burada check yaprik her get te kontrol et
app.use('*',checkUser)
app.use('/',pageRouter)
app.use('/photos',photoRouter)
app.use('/users',userRouter)
/*
//statick
app.use(express.static('public'))
app.get('/',(req,res)=>{
res.render('index')
})
app.get('/about',(req,res)=>{
res.render('about')
})
*/
app.listen(port,()=>{
console.log('baglandik')
})