import * as _homer0_jimple from '@homer0/jimple'; import { J as Jimpex } from '../../index-DAUqbQ6h.js'; import { Response, NextFunction } from 'express'; import { PathUtils } from '@homer0/path-utils'; import '../../types/express.js'; import '../../types/http.js'; import 'https'; import 'http'; import 'spdy'; import 'node-fetch'; import '../../types/utils.js'; import '@homer0/simple-logger'; import '@homer0/simple-config'; import '@homer0/events-hub'; /** * The options to create a {@link SendFile} function. * * @group Services/SendFile */ type SendFileGeneratorOptions = { /** * A dictionary with the dependencies to inject. */ inject: { pathUtils: PathUtils; }; }; /** * The options for the function that actually serves a file. * * @group Services/SendFile */ type SendFileOptions = { /** * The response object sent by the application. Necessary to write the file. */ res: Response; /** * The path of the file to serve. Depending on the `from` option, it will be either * relative to the project root, or the application executable. */ filepath: string; /** * The name of a location on the `pathUtils` service from where the `filepath` is * relative to. It can be `app` for the directory containing the application executable, * or `project` for the project root. It could also be any other location that the * implementation may have registered. * * @default 'app' */ from?: string; /** * The function to move to the next middleware. It can be used to report an error in * case the file can't be served. * * @default {() => {}} */ next?: NextFunction; }; /** * The type of the function that serves a file. * This is exported to make it easy to type the dependency injection. * * @group Services/SendFile */ type SendFile = (options: SendFileOptions) => void; /** * Generates a function to send files on the application response. * * @param options To inject the required dependencies. * @example * * Basic usage * * // Let's say this is inside an Express middleware. * // Get the function * const send = sendFile(pathUtils); * send({ res, filepath: 'some-file.html', next }); * // If your app is on "/app/index.js", this will send "/app/some-file.html". * * @group Services * @group Services/SendFile */ declare const sendFile: ({ inject: { pathUtils } }: SendFileGeneratorOptions) => SendFile; /** * The service provider that once registered on the container will set the result of * {@link sendFile} as the `sendFile` service. * * @example * * // Register it on the container * container.register(sendFileProvider); * // Getting access to the service instance * const sendFile = container.get('sendFile'); * * @group Providers * @group Services/SendFile */ declare const sendFileProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn>; export { type SendFile, type SendFileGeneratorOptions, type SendFileOptions, sendFile, sendFileProvider };