Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
feat(server/index.dev): add both http and https servers in prod
Browse files Browse the repository at this point in the history
feat(server/index.dev): add both http and https servers in prod
  • Loading branch information
Metnew committed Sep 19, 2017
1 parent 3960490 commit a33c3e9
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,27 @@
* @file
*/
import express from 'express'
import http from 'http'
import spdy from 'spdy'
import chalk from 'chalk'
//
// Mount our server-side code to server
import server from './server'
import {serverOptions as options} from './config'

const app: express$Application = express()
const PORT: number = +process.env.PORT || 3000
const httpsPORT: number = +process.env.PORT || 3030
const httpPORT: number = +process.env.PORT || 3000

server(app)

const decoratedProductionServer = server(app)
spdy.createServer(options, app).listen(httpsPORT, () => {
console.log(
chalk.red(`HTTPS SERVER IS LISTENING ON https://127.0.0.1:${httpsPORT}`)
)
})

spdy.createServer(options, decoratedProductionServer).listen(PORT, () => {
console.log(chalk.green(`SERVER IS LISTENING ON ${PORT}`))
http.createServer(app).listen(httpPORT, () => {
console.log(
chalk.green(`HTTP SERVER IS LISTENING ON http://localhost:${httpPORT}`)
)
})

0 comments on commit a33c3e9

Please sign in to comment.