support.js 482 B

123456789101112131415161718192021
  1. 'use strict'
  2. const fp = require('fastify-plugin')
  3. // the use of fastify-plugin is required to be able
  4. // to export the decorators to the outer scope
  5. module.exports = fp(function (fastify, opts, next) {
  6. fastify.decorate('someSupport', function () {
  7. return 'hugs'
  8. })
  9. next()
  10. })
  11. // If you prefer async/await, use the following
  12. //
  13. // module.exports = fp(async function (fastify, opts) {
  14. // fastify.decorate('someSupport', function () {
  15. // return 'hugs'
  16. // })
  17. // })