UNPKG

blazepress

Version:

A rapid web application development platform for Node.js

42 lines (26 loc) 660 B
const ActiveSet = require( '../ActiveSet' ) const Service = require( '../Service' ) class WebServer extends Service { constructor( server, port, address ) { super() this.server = server this.port = port this.address = address this.requestHandlers = new ActiveSet() } start() { this.emit( 'starting' ) if( !this.server ) { this.emit( 'started' ) return } this.port = this.port || 3000 this.address = this.address || '127.0.0.1' this.host = this.host || 'localhost' this.server.listen( this.port, this.address, () => { this.emit( 'started' ) this.emit( 'listening' ) }) } } module.exports = WebServer