Skip to content

Commit

Permalink
Use http package
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Dzialocha committed Nov 28, 2017
1 parent 926d6b2 commit 5279351
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions server/httpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const chalk = require('chalk')
const cors = require('cors')
const express = require('express')
const http = require('http')
const path = require('path')

const defaultOptions = {
Expand All @@ -13,15 +14,16 @@ class HTTPServer {
constructor(options) {
this.options = Object.assign({}, defaultOptions, options)

this.server = express()
this.app = express()

this.server.set('port', process.env.PORT || this.options.port)
this.server.use(cors({ origin: '*' }))
this.server.use(express.static(path.join(__dirname, '..', 'dist')))
this.app.use(cors({ origin: '*' }))
this.app.use(express.static(path.join(__dirname, '..', 'dist')))

this.server = http.createServer(this.app)
}

open() {
const port = this.server.get('port')
const port = process.env.PORT || this.options.port

this.server.listen(port, () => {
console.log(chalk.green('HTTP Server is running'), `(port ${port})`)
Expand Down

0 comments on commit 5279351

Please sign in to comment.