Skip to content

Commit

Permalink
expose used http server instance
Browse files Browse the repository at this point in the history
  • Loading branch information
jkyberneees committed Jun 2, 2019
1 parent a332841 commit d9420d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -45,6 +45,8 @@ const service = require('restana')({
```js
// accessing service configuration
service.getConfigOptions()
// accessing restana HTTP server instance
service.getServer()
```

#### Example usage:
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Expand Up @@ -125,6 +125,7 @@ declare namespace restana {
}

interface Service<P extends Protocol> {
getServer(): Server<P>,
getConfigOptions(): Options<P>
use(middleware: RequestHandler<P>, context?: {}): void
route(
Expand Down
6 changes: 6 additions & 0 deletions index.js
Expand Up @@ -72,6 +72,12 @@ module.exports = (options = {}) => {

// the "restana" service interface
const app = {
/**
* HTTP server instance
*/
getServer () {
return server
},
/**
* Application configuration options reference
*/
Expand Down
1 change: 1 addition & 0 deletions tests.js
Expand Up @@ -11,6 +11,7 @@ describe('Restana Web Framework - Smoke', () => {

it('service options are exposed through getServiceOptions', (done) => {
expect(typeof service.getConfigOptions().server).to.equal('object')
expect(service.getConfigOptions().server).to.equal(service.getServer())
done()
})

Expand Down

0 comments on commit d9420d0

Please sign in to comment.