Skip to content

Commit

Permalink
Merge pull request #32 from jkyberneees/expose-service-options
Browse files Browse the repository at this point in the history
Expose service options
  • Loading branch information
jkyberneees authored Apr 5, 2019
2 parents 111a0ec + d82c451 commit 337ea5e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const service = require('restana')({
- `defaultRoute`: Default route handler when no route match occurs. Default value: `((req, res) => res.send(404))`
- `disableResponseEvent`: If `TRUE`, there won't be `response` events triggered on the `res` object. Default value: `FALSE`

```js
// accessing service configuration
service.getConfigOptions()
```

#### Example usage:
```js
const service = require('restana')({
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ module.exports = (options = {}) => {
/**
* Application configuration options reference
*/
options,
getConfigOptions () {
return options
},

/**
* Register global middleware
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "restana",
"version": "2.12.0",
"version": "2.12.1",
"description": "Super fast and minimalist web framework for building REST micro-services.",
"main": "index.js",
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ describe('Restana Web Framework - Smoke', () => {
let server
const service = require('./index')({ server: require('./libs/turbo-http') })

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

it('should successfully register service routes', async () => {
service.get(
'/pets/:id',
Expand Down

0 comments on commit 337ea5e

Please sign in to comment.