UNPKG

fastify-cli

Version:

Run a fastify route with one command!

31 lines (24 loc) 875 B
import path from 'node:path' import AutoLoad from '@fastify/autoload' import { fileURLToPath } from 'node:url' const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) // Pass --options via CLI arguments in command to enable these options. export const options = {} export default async function (fastify, opts) { // Place here your custom code! // Do not touch the following lines // This loads all plugins defined in plugins // those should be support plugins that are reused // through your application fastify.register(AutoLoad, { dir: path.join(__dirname, 'plugins'), options: Object.assign({}, opts) }) // This loads all plugins defined in routes // define your routes in one of these fastify.register(AutoLoad, { dir: path.join(__dirname, 'routes'), options: Object.assign({}, opts) }) }