-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (51 loc) · 1.63 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
// node m
const path = require('path')
// installed m
const express = require('express')
const layout = require('express-ejs-layouts')
const cookieParser = require('cookie-parser')
const bodyparser = require('body-parser');
const file = require('express-fileupload');
const session = require("express-session");
const MongoStore = require("connect-mongo");
const { connect ,conn } = require('./config/db');
var flash = require('connect-flash');
const mong=new MongoStore({mongoUrl:"mongodb://127.0.0.1:27017/",dbName:"tsuki"})
const app = express()
const urls=require('./config/urls.json');
app.locals.preloder=false
// view engine setup
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'ejs')
app.set('layout', 'viewslayout')
app.use(layout)
app.use(require("./modules/setheader"))
app.use(bodyparser.json())
app.use(bodyparser.urlencoded({ extended: false }))
app.use(cookieParser())
app.use(express.static(path.join(__dirname, 'public')))
app.use(
session({
secret: "nnnn",
resave: false,
saveUninitialized: false,
unset: "destroy",
store: mong,
cookie: { maxAge: 24 * 60 * 60 * 1000 },
})
);
app.use(flash());
app.use(file())
app.use(require('./modules/hostname'))
app.use(urls.routes.index, require('./routes/index'))
app.use(urls.routes.dashbord, require('./routes/dashbord'))
app.use(urls.routes.anime, require('./routes/anime'))
app.use(urls.routes.api,require('./routes/api.v1'))
app.get('*', (req, res) => {
res.sendStatus(404)
})
var port=9000;
app.listen(port, () => {
console.log(`starting app\napp runing in port ${port}\napp url : http://127.0.0.1:${port}`);
connect();
});