mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 01:53:55 +00:00
34 lines
578 B
JavaScript
34 lines
578 B
JavaScript
'use strict'
|
|
|
|
const http = require('http')
|
|
|
|
class Server {
|
|
|
|
constructor (nuxt) {
|
|
this.nuxt = nuxt
|
|
this.server = http.createServer(this.render.bind(this))
|
|
return this
|
|
}
|
|
|
|
render (req, res) {
|
|
this.nuxt.render(req, res)
|
|
return this
|
|
}
|
|
|
|
listen (port, host) {
|
|
host = host || 'localhost'
|
|
port = port || 3000
|
|
this.server.listen(port, host, () => {
|
|
console.log('Ready on http://%s:%s', host, port) // eslint-disable-line no-console
|
|
})
|
|
return this
|
|
}
|
|
|
|
close (cb) {
|
|
return this.server.close(cb)
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = Server
|