fastify / fastify-autoload

Require all plugins in a directory
MIT License
333 stars 67 forks source link

Allow `autoConfig` with callback #381

Closed jean-michelet closed 5 months ago

jean-michelet commented 5 months ago

Can be usefull to autoload plugins:

import fastifyMysql from "@fastify/mysql";

export const autoConfig = (fastify) => {
  return {
    promise: true,
    host: fastify.config.MYSQL_HOST,
    user: fastify.config.MYSQL_USER,
    password: fastify.config.MYSQL_PASSWORD,
    database: fastify.config.MYSQL_DATABASE,
    port: Number(fastify.config.MYSQL_PORT)
  }
}

export default fastifyMysql
mcollina commented 5 months ago

@climba03003 ptal