@piggly/fastify-chassis
Version:
An ESM/CommonJS toolkit to help you to do common operations in your back-end applications with Fastify and NodeJS.
21 lines (20 loc) • 811 B
TypeScript
import type { HookHandlerDoneFunction, FastifyRequest, FastifyReply } from 'fastify';
/**
* BasicAuthMiddleware is a middleware that checks if the request
* is authenticated using Basic Authentication.
*
* If request is not authenticated, it will:
* - Publish UnauthorizedAccessEvent.
* - Return UnauthorizedError.
*
* @param {Object} expected - The expected username and password.
* @param {string} expected.username - The expected username.
* @param {string} expected.password - The expected password.
* @returns The middleware function.
* @since 1.0.0
* @author Caique Araujo <caique@piggly.com.br>
*/
export declare const BasicAuthMiddleware: (expected: {
password: string;
username: string;
}) => (request: FastifyRequest, reply: FastifyReply, done: HookHandlerDoneFunction) => void;