forked from vgalante2/WinBig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
71 lines (56 loc) · 1.62 KB
/
server.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
require('dotenv').config()
const sequelize = require('./db/client')
const express = require('express')
const routes = require('./routes')
const { engine } = require('express-handlebars')
const session = require('express-session')
const SequelizeStore = require("connect-session-sequelize")(session.Store)
const store = new SequelizeStore({ db: sequelize })
const {User,Event,Bet} = require('./models')
const app = express()
const PORT = process.env.PORT||3333
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(session(
{
secret: process.env.SESSION_SECRET,
store,
resave: false,
saveUninitialized: true,
cookie: { maxAge: 1000000 }
}
))
// Create a GET route for every file in public
app.use(express.static('public'))
app.engine('handlebars', engine());
app.set('view engine', 'handlebars');
app.use('/', routes)
// function flip(){
// if(Math.floor(Math.random()*2)){
// return {outcome: 'heads'}
// }
// return {outcome: 'tails'}
// }
// async function delay(time){
// return new Promise(res=>setTimeout(res,time))
// }
// async function flipCoins(){
// const event = await Event.create({
// event_name: "coinflip",
// odds: {
// heads: 0.50,
// tails: 0.50
// }
// })
// await delay(25000)
// console.log('hi')
// event.resolveBets(flip())
// };
// Set interval for the repetitive task
sequelize.sync({force: false})
.then(()=>{
app.listen(PORT,() => {
console.log('Server running on port: ', PORT)
// setInterval(flipCoins, 30000)
})
})