-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
74 lines (57 loc) · 2.32 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
71
72
73
74
const express = require("express"),
bodyParser = require("body-parser"),
moment = require("moment"),
mongoose = require("mongoose"),
compression = require("compression"),
methodOverride = require("method-override"),
dotenv = require("dotenv"),
expressSanitizer = require('express-sanitizer'),
cookieSession = require("cookie-session"),
app = express();
dotenv.config();
app.use(compression());
app.use(expressSanitizer());
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true, parameterLimit: 50000 }))
app.set("view engine", "ejs");
app.engine('ejs', require('ejs').__express);
app.use(express.static(__dirname + '/public'));
var redirectToHTTPS = require('express-http-to-https').redirectToHTTPS
app.use(redirectToHTTPS([/localhost:(\d{4})/], [/\/insecure/], 301));
app.use(methodOverride("_method"));
app.use(cookieSession({
maxAge : 360*3600*1000,
keys : ['vthacks2020.werebuildingthenextgenmarketresearchaithatdoeswonders']
}));
var MemoryStore = require("memorystore")(require('express-session'));
app.use(require("express-session")({
secret : "scrkeyoiash389wh31207891ios=iqasimwani&jda08124sadjas.todayis14jan2020,330am.",
store: new MemoryStore({
checkPeriod: 86400000 // prune expires entries every 24h
}),
resave : false,
saveUninitialized : false
}));
mongoose.set('useCreateIndex', true);
mongoose.set('useFindAndModify', false);
mongoose.Promise = global.Promise;
mongoose.connect("mongodb://"+process.env.mongoDB+"/marketanalytics",{ useNewUrlParser: true , useUnifiedTopology: true});
app.use(function(req, res, next){
res.set('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
next();
});
const searchEngine = require("./routes/search");
// marketplaceRoutes = require("./routes/marketplace"),
// endpointRoutes = require("./routes/endpoint");
// app.use("/produce", endpointRoutes);
// app.use("/marketplace", marketplaceRoutes);
// app.use("/", indexRoutes);
app.use("/search", searchEngine);
// app.get("/", function(req, res){
// return res.render("partials/landing/index");
// });
app.get("*",(req, res)=>{
return res.send("Hello World");
});
app.listen(process.env.PORT || 2718, process.env.IP,()=>{
console.log("Market Analytics Server Connected");
});