1.1.1 • Published 4 years ago
@dukai.net/hapi-time v1.1.1
hapi-time.js
Hapi response time management component
Install:
npm install @dukai.net/hapi-time
or:
yarn add @dukai.net/hapi-time
Use:
path: '/api/v1/orange/{id}',
method: 'GET',
handler: async (request, h) => {
try {
h.timerStart(request, 'mycalltimer');
const out = await dal.orange.getSomething(args);
h.timerEnd(request, 'mycalltimer');
} catch (err) {
return boom.boomify(err, { statusCode: 400 });
}
},
The measured and named times will be injected into the response header with x-time-(name) format.
The full time of the request will be under the name: x-time-request.