@chainizer/support-app
Advanced tools
Comparing version 1.0.0-alpha.33 to 1.0.0-alpha.34
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="1.0.0-alpha.34"></a> | ||
# [1.0.0-alpha.34](https://gitlab.com/chainizer/chainizer-support-node/compare/v1.0.0-alpha.33...v1.0.0-alpha.34) (2018-05-23) | ||
### Bug Fixes | ||
* inverse logged port and hostname when app start ([33e185a](https://gitlab.com/chainizer/chainizer-support-node/commit/33e185a)) | ||
<a name="1.0.0-alpha.33"></a> | ||
@@ -8,0 +19,0 @@ # [1.0.0-alpha.33](https://gitlab.com/chainizer/chainizer-support-node/compare/v1.0.0-alpha.32...v1.0.0-alpha.33) (2018-05-23) |
@@ -14,5 +14,6 @@ /// <reference types="node" /> | ||
export interface Hook { | ||
(server: Server): Promise<any>; | ||
(): Promise<any>; | ||
} | ||
export declare function getExpressApp(): Express; | ||
export declare function getServer(): Server; | ||
export declare function getHooks(): { | ||
@@ -19,0 +20,0 @@ startup: Hook[]; |
@@ -33,2 +33,6 @@ "use strict"; | ||
exports.getExpressApp = getExpressApp; | ||
function getServer() { | ||
return server; | ||
} | ||
exports.getServer = getServer; | ||
function getHooks() { | ||
@@ -51,3 +55,3 @@ return hooks; | ||
for (const hook of hooks.startup) { | ||
yield hook(server); | ||
yield hook(); | ||
} | ||
@@ -60,3 +64,3 @@ terminus(server, { | ||
for (const hook of hooks.health) { | ||
yield hook(server); | ||
yield hook(); | ||
} | ||
@@ -69,3 +73,3 @@ }) | ||
for (const hook of hooks.shutdown) { | ||
yield hook(server); | ||
yield hook(); | ||
} | ||
@@ -86,3 +90,3 @@ }); | ||
server.listen(c.port, c.hostname, () => { | ||
support_winston_1.logger().info('app listening on %s:%s', c.port, c.hostname); | ||
support_winston_1.logger().info('app listening on %s:%s', c.hostname, c.port); | ||
resolve(server); | ||
@@ -89,0 +93,0 @@ }); |
{ | ||
"name": "@chainizer/support-app", | ||
"version": "1.0.0-alpha.33", | ||
"version": "1.0.0-alpha.34", | ||
"description": "App lifecycle management.", | ||
@@ -5,0 +5,0 @@ "author": "Thibault Morin", |
@@ -20,3 +20,3 @@ import {config} from '@chainizer/support-config'; | ||
export interface Hook { | ||
(server: Server): Promise<any> | ||
(): Promise<any> | ||
} | ||
@@ -37,2 +37,6 @@ | ||
export function getServer(): Server { | ||
return server; | ||
} | ||
export function getHooks() { | ||
@@ -54,3 +58,3 @@ return hooks; | ||
for (const hook of <Hook[]> hooks.startup) { | ||
await hook(server); | ||
await hook(); | ||
} | ||
@@ -64,3 +68,3 @@ | ||
for (const hook of <Hook[]> hooks.health) { | ||
await hook(server); | ||
await hook(); | ||
} | ||
@@ -72,3 +76,3 @@ } | ||
for (const hook of <Hook[]> hooks.shutdown) { | ||
await hook(server); | ||
await hook(); | ||
} | ||
@@ -88,3 +92,3 @@ }, | ||
server.listen(c.port, c.hostname, () => { | ||
logger().info('app listening on %s:%s', c.port, c.hostname); | ||
logger().info('app listening on %s:%s', c.hostname, c.port); | ||
resolve(server); | ||
@@ -91,0 +95,0 @@ }); |
import 'mocha'; | ||
import {expect} from 'chai'; | ||
import {spy} from 'sinon'; | ||
import {clearHooks, getExpressApp, getHooks, HookType, registerHook, startApp} from '../src/main'; | ||
import {clearHooks, getExpressApp, getHooks, getServer, HookType, registerHook, startApp} from '../src/main'; | ||
import {config} from '@chainizer/support-config'; | ||
@@ -50,2 +50,6 @@ | ||
it('should return server', () => { | ||
expect(getServer()).to.exist; | ||
}); | ||
}); |
11520
250