-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (23 loc) · 664 Bytes
/
index.js
File metadata and controls
27 lines (23 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict'
const fp = require('fastify-plugin')
const doc = require('@dnlup/doc')
function plugin (fastify, opts, done) {
try {
fastify.decorate('eventLoopUtilizationSupported', doc.eventLoopUtilizationSupported)
fastify.decorate('resourceUsageSupported', doc.resourceUsageSupported)
fastify.decorate('gcFlagsSupported', doc.gcFlagsSupported)
const sampler = doc(opts)
fastify.decorate('metrics', sampler)
fastify.addHook('onClose', (instance, done) => {
sampler.stop()
done()
})
done()
} catch (error) {
done(error)
}
}
module.exports = fp(plugin, {
fastify: '^3.0.0',
name: '@dnlup/fastify-doc'
})