zents
Version:
ZenTS is a Node.js & TypeScript MVC-Framework for building rich web applications, released as free and open-source software under the MIT License. It is designed for building web applications with modern tools and design patterns.
48 lines • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZenApp = void 0;
const config_1 = require("../config/config");
const logger_1 = require("../log/logger");
const AutoLoader_1 = require("./AutoLoader");
const Server_1 = require("../http/Server");
const validateInstallation_1 = require("../filesystem/validateInstallation");
class ZenApp {
constructor() {
/**
* Inidicates if the application has completly booted.
*/
this.isBooted = false;
}
/**
* This function boots the entire application, prepares the config, Registry and starts the webserver.
*/
async boot(config) {
await config_1.loadConfig(config);
logger_1.createLogger();
await validateInstallation_1.validateInstallation();
const autoloader = new AutoLoader_1.AutoLoader();
this.registry = await autoloader.createRegistry();
await this.startServer();
this.isBooted = true;
}
destroy() {
this.nodeServer.close();
}
/**
* Creates a new webserver, which can be configured inside the config.web property (see {@link config} for more details)
*/
async startServer() {
return new Promise((resolve) => {
const server = new Server_1.Server(this.registry);
this.nodeServer = server.listen({
host: config_1.config.web.host,
port: config_1.config.web.port,
}, () => {
logger_1.log.success(`ZenTS web-server listening on http://${config_1.config.web.host}:${config_1.config.web.port}`);
resolve();
});
});
}
}
exports.ZenApp = ZenApp;
//# sourceMappingURL=ZenApp.js.map