Skip to content

fastify-papr-plugin 1.1.2

Install from the command line:
Learn more about npm packages
$ npm install @flash-tecnologia/fastify-papr-plugin@1.1.2
Install via package.json:
"@flash-tecnologia/fastify-papr-plugin": "1.1.2"

About this version

fastify-awilix-plugin

A dependency injection plugin for fastify framework.

Getting started

yarn add @flash-tecnologia/fastify-awilix-plugin awilix

Next, set up the plugin:

import { fastifyAwilixPlugin } from '@flash-tecnologia/fastify-awilix-plugin'

Next, set up the plugin:

declare module '@flash-tecnologia/fastify-awilix-plugin' {
  interface Cradle {
    dateService: Date
    printDate: string
  }
}

const dateService = () => new Date();
const printService = ({dateService: Date}) => dateService().toDateString()

fastify.register(fastifyAwilixPlugin.default, {
      module: {
        dateService: asFunction(dateService).singleton(),
        printDate: asFunction(printService).singleton()
}})

server.get(
      '/status',
      async (request) => {
        const cradle = request.diScope.cradle
        return cradle.printDate
      }
    )
    

Details


Assets

  • fastify-papr-plugin-1.1.2.tgz

Download activity

  • Total downloads 1
  • Last 30 days 0
  • Last week 0
  • Today 0