-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
66 lines (47 loc) · 1.67 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
import dotenv from 'dotenv'
dotenv.config();
import express from "express";
import cors from 'cors';
import flash from 'express-flash';
// we use this module to connect the route path
import {join} from 'path';
import home from './routes/home.js';
import Event from './routes/event.js';
import Connect_data from "./database/connect_db.js";
import Admin from './routes/admin.js';
import home_event from './controller/home_controller.js';
import cookieParser from 'cookie-parser';
import paymentRout from './routes/payments.js'
import authUser from './middleware/authUser.js';
import authPayment from './middleware/authPayment.js';
const app=express();
const port=process.env.PORT || 5000;
// data url
const Data_url=process.env.Data_url//'mongodb://localhost:27017/spirit_db';
// data base connection
Connect_data(Data_url);
// here we are going to use express.static() function
// so that we can render the file of public folder
app.use(express.static(join(process.cwd(),'public')));
app.use(express.urlencoded({extended:false}));
// core policy
app.use(cors());
// app.use(flash());
// we can use cookie-parser as a middleware
app.use(cookieParser());
app.set('views','./view')
app.set('view engine','ejs');
// routers for home page content
app.use('/',home);
// router for event page content
app.use('/events', Event);
// payments route
app.use('/payments',authUser,paymentRout)
// app.post('/create/orderId',home_event.creatOrer)
// app.post('/api/payment/verify',home_event.verifyOrder)
// this is admin routes☠️☠️☠️
app.use('/admin', Admin);
// app.use('/admin_home', adm_home);
app.listen(port, ()=>{
console.log(`server is running at http://localhost:${port}`);
})