Skip to content

Commit d9420d0

Browse files
committed
expose used http server instance
1 parent a332841 commit d9420d0

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const service = require('restana')({
4545
```js
4646
// accessing service configuration
4747
service.getConfigOptions()
48+
// accessing restana HTTP server instance
49+
service.getServer()
4850
```
4951

5052
#### Example usage:

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ declare namespace restana {
125125
}
126126

127127
interface Service<P extends Protocol> {
128+
getServer(): Server<P>,
128129
getConfigOptions(): Options<P>
129130
use(middleware: RequestHandler<P>, context?: {}): void
130131
route(

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ module.exports = (options = {}) => {
7272

7373
// the "restana" service interface
7474
const app = {
75+
/**
76+
* HTTP server instance
77+
*/
78+
getServer () {
79+
return server
80+
},
7581
/**
7682
* Application configuration options reference
7783
*/

tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ describe('Restana Web Framework - Smoke', () => {
1111

1212
it('service options are exposed through getServiceOptions', (done) => {
1313
expect(typeof service.getConfigOptions().server).to.equal('object')
14+
expect(service.getConfigOptions().server).to.equal(service.getServer())
1415
done()
1516
})
1617

0 commit comments

Comments
 (0)