57 lines
1.9 KiB
JavaScript
57 lines
1.9 KiB
JavaScript
"use strict";
|
|
var __extends = (this && this.__extends) || (function () {
|
|
var extendStatics = function (d, b) {
|
|
extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
return extendStatics(d, b);
|
|
};
|
|
return function (d, b) {
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var App_1 = require("./App");
|
|
var http = require("http");
|
|
var start = (function (_super) {
|
|
__extends(start, _super);
|
|
function start() {
|
|
var _this = _super.call(this) || this;
|
|
_this.server = http.createServer(_this.AppMain);
|
|
_this.run();
|
|
return _this;
|
|
}
|
|
start.prototype.run = function () {
|
|
this.server.listen(this.port);
|
|
this.server.on('error', this.onError);
|
|
this.server.on('listening', this.onListening);
|
|
};
|
|
start.prototype.onError = function (error) {
|
|
if (error.syscall !== 'listen') {
|
|
throw error;
|
|
}
|
|
var bind = typeof this.port === 'string'
|
|
? 'Pipe ' + this.port
|
|
: 'Port ' + this.port;
|
|
switch (error.code) {
|
|
case 'EACCES':
|
|
console.error(bind + ' requires elevated privileges');
|
|
process.exit(1);
|
|
break;
|
|
case 'EADDRINUSE':
|
|
console.error(bind + ' is already in use');
|
|
process.exit(1);
|
|
break;
|
|
default:
|
|
throw error;
|
|
}
|
|
};
|
|
start.prototype.onListening = function () {
|
|
console.log('App is run: http://127.0.0.1:3000');
|
|
};
|
|
return start;
|
|
}(App_1.App));
|
|
new start();
|