-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (48 loc) · 1.32 KB
/
index.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
const express = require('express')
const app = express()
const server = require('http').createServer(app)
const config = require('./config')
const io = require('socket.io')(server)
const bodyParser = require('body-parser')
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
// Microservices toolkit
const seneca = require('seneca')({
log: 'silent'
})
.use('basic')
.use('entity')
.use('./modules/product')
.use('./modules/client')
.use('./modules/bid')
.use('./modules/auction')
// Api expose
const apiAuction = require('./api/auction')(seneca, io)
app.use('/api', apiAuction)
// View engine
app.set('view engine', 'jade')
app.set('views', './views')
// Routes
const auctionRouter = require('./routes/auction')(seneca)
app.use('/auction', auctionRouter)
app.get('/', (request, response) => {
response.redirect('/auction/auctionWatch')
})
// Static paths
app.use(express.static(__dirname + '/public'))
// When a socket connect
io.on('connection', (socket) => {
console.log('Someone is connected.')
})
// Demo purpose
const mock = require('./tests/mock')(seneca, {
auctionSingleBidderId: 'auctionWatchSingle',
auctionMultipleBiddersId: 'auctionWatch',
clientId: 'me'
});
mock.all().then(() => {
console.log('> app running on port:', config.port)
server.listen(config.port)
})