-
Notifications
You must be signed in to change notification settings - Fork 109
/
app.js
70 lines (48 loc) · 1.61 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
require('dotenv').config();
const express = require("express");
const bodyParser = require("body-parser");
const path = require('path');
const app = express();
const moment = require('moment');
const hbs = require('nodemailer-express-handlebars');
const {transporter}=require("./helpers/emailHelpers")
const flash = require('express-flash');
const Admin=require("./model/admin")
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static("public"));
const NGO=require("./model/ngo")
const isAdmin=require("./middleware/isAdmin");
//connecting to database
require("./db/db")
// app.use(flash());
app.set('view engine', 'ejs');
const handlebarOptions = {
viewEngine: {
extName: ".handlebars",
partialsDir: path.resolve('./views'),
defaultLayout: false,
},
viewPath: path.resolve('./views'),
extName: ".handlebars",
}
transporter.use('compile', hbs(handlebarOptions));
transporter.verify().then(console.log).catch(console.error);
app.locals.moment = moment;
//load routers
const userRouter=require("./routers/userRoutes")
const NgoRouter=require("./routers/NgoRoutes")
const adminRouter=require("./routers/adminRoutes")
//api endpoints
app.use(userRouter)
app.use(NgoRouter)
app.use(adminRouter)
app.listen( process.env.port|| 3000,function(){
console.log("server is running on port 3000 ");
});
// Route for policies.ejs
app.get('/policies', (req, res) => {
res.render('policies'); // Ensure policies.ejs is in the views directory
});
app.get("/*",(req,res) =>{
res.render("Error");
});