@nearform/udaru-trail

1.0.0 • Public • Published

@nearform/udaru-trail

npm travis coveralls

udaru-trail is a small package which adds trail auditing capabilities to udaru via its hooks.

Integrating into udaru

Once you have udaru and trail instantiated, simply call the register function:

const udaru = require('@nearform/udaru-core')
const { TrailsManager } = require('@nearform/trail-core')
const { register } = require('@nearform/udaru-trail')

const udaruInstance = udaru()
const trailInstance = new TrailsManager()

// The third argument is option and is a list of udaru hooks you want to log. If omitted, all supported udaru hooks will be logged.
register(udaruInstance, trailInstance, ['authorize:isUserAuthorized'])

Integrating into udaru and HAPI

Integration is supported via udaru-hapi-plugin.

Register the UdaruTrailHapiPlugin after UdaruPlugin and after TrailPlugin and BEFORE starting the server:

const TrailPlugin = require('@nearform/trail-hapi-plugin')
const UdaruPlugin = require('@nearform/udaru-hapi-plugin')
const { UdaruTrailHapiPlugin } = require('@nearform/udaru-trail')
const Hapi = require('hapi')

const server = Hapi.Server({port: 3000})

await this.server.register({plugin: UdaruPlugin})
await this.server.register({plugin: TrailPlugin})
await this.server.register({plugin: UdaruTrailHapiPlugin})

await this.server.start()

Testing, benching & linting

Before running tests, make sure you have a working test environment for both udaru-core and trail-core packages.

To run tests:

npm run test

Note: running the tests will output duplicate keys errors in Postgres logs, this is expected, as the error handling of those cases is part of what is tested.

To lint the repository:

npm run lint

To fix (most) linting issues:

npm run lint -- --fix

To create coverage reports:

npm run coverage

License

Copyright nearForm Ltd 2018. Licensed under MIT.

Dependents (0)

Package Sidebar

Install

npm i @nearform/udaru-trail

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

49.3 kB

Total Files

23

Last publish

Collaborators

  • lucalanziani
  • donal.moynihan
  • simoneb
  • eamonn.frisby