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