@thi.ng/server
Version:
Minimal HTTP server with declarative routing, static file serving and freely extensible via pre/post interceptors
19 lines • 892 B
TypeScript
import type { Predicate } from "@thi.ng/api";
import type { Interceptor, RequestCtx } from "../api.js";
/**
* Pre-interceptor. Checks if current route has `auth` flag enabled and if so
* applies given predicate function to current {@link RequestCtx}. If the
* predicate returns false, the server responds with
* {@link ServerResponse.unauthorized} and any following pre-interceptors and
* the main route handler will be skipped. Only post-interceptors (if any) will
* still be executed.
*
* @remarks
* If this interceptor is used with the {@link sessionInterceptor} interceptor,
* it MUST come after it, otherwise the session information will not yet be
* available in the context object given to the predicate.
*
* @param pred
*/
export declare const authenticateWith: <CTX extends RequestCtx>(pred: Predicate<CTX>) => Interceptor<CTX>;
//# sourceMappingURL=auth-route.d.ts.map