-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
71 lines (42 loc) · 1.26 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
70
import express from 'express';
import dotenv from 'dotenv';
import conn from './db.js';
import cookieParser from 'cookie-parser';
import methodOverride from 'method-override';
import pageRoute from './routes/pageRoute.js';
import photoRoute from './routes/photoRoute.js';
import userRoute from './routes/userRoute.js';
import { checkUser } from './middlewares/authMiddleware.js';
import fileUpload from 'express-fileupload';
import { v2 as cloudinary } from 'cloudinary';
dotenv.config();
cloudinary.config({
cloud_name:process.env.CLOUD_NAME,
api_key:process.env.CLOUD_API_KEY,
api_secret:process.env.CLOUD_API_SECRET,
})
// connection DB
conn();
const app = express();
const port = process.env.PORT;
//ejs template engine
app.set("view engine", "ejs");
// static files middleware
app.use(express.static('public'));
app.use(express.json());
app.use(express.urlencoded({extended:true}));
app.use(cookieParser());
app.use(fileUpload({useTempFiles: true}));
app.use(
methodOverride('_method',{
methods: ['POST', 'GET'],
})
);
//routes
app.use("*", checkUser);
app.use('/',pageRoute);
app.use('/photos',photoRoute);
app.use('/users',userRoute);
app.listen(port,()=>{
console.log(`Application running on port brocum devams: ${port}`);
});