UNPKG

904 BJavaScriptView Raw
1import fs from 'fs'
2import express from 'express'
3import spdy from 'spdy'
4import config, { args } from './helpers/config'
5import appConfig from './config/app'
6import errorRoutes from './routes/errors'
7import socketRoutes from './routes/sockets'
8import { apiRouter } from './routes/api'
9import { mainRouter } from './routes/main'
10import { searchRouter } from './routes/search'
11
12const env = process.env.NODE_ENV || 'development'
13const port = config[env].port || args.p || args.port || 3000
14const spdyOptions = {
15 key: fs.readFileSync(config[env].certKey),
16 cert: fs.readFileSync(config[env].cert)
17}
18
19export const app = express()
20export const server = spdy.createServer(spdyOptions, app)
21
22appConfig(app)
23
24app.use('/', mainRouter)
25app.use('/api', apiRouter)
26app.use('/search', searchRouter)
27
28socketRoutes(server)
29
30errorRoutes(app)
31
32server.listen(port)
33console.info('Bkmrkd has been started on port 3000.')