Preview: buildAuthenticatedRouter.d.ts
Size: 1.51 KB
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/@adminjs/express/lib/buildAuthenticatedRouter.d.ts
import AdminJS from "adminjs";
import express, { Router } from "express";
import session from "express-session";
import { AuthenticationOptions, FormidableOptions } from "./types.js";
/**
* @typedef {Function} Authenticate
* @memberof module:@adminjs/express
* @description
* function taking 2 arguments email and password
* @param {string} [email] email given in the form
* @param {string} [password] password given in the form
* @return {CurrentAdmin | null} returns current admin or null
*/
/**
* Builds the Express Router which is protected by a session auth
*
* Using the router requires you to install `express-session` as a
* dependency. Normally express-session holds session in memory, which is
* not optimized for production usage and, in development, it causes
* logging out after every page refresh (if you use nodemon).
* @static
* @memberof module:@adminjs/express
* @example
* const ADMIN = {
* email: 'test@example.com',
* password: 'password',
* }
*
* AdminJSExpress.buildAuthenticatedRouter(adminJs, {
* authenticate: async (email, password) => {
* if (ADMIN.password === password && ADMIN.email === email) {
* return ADMIN
* }
* return null
* },
* cookieName: 'adminjs',
* cookiePassword: 'somePassword',
* }, [router])
*/
export declare const buildAuthenticatedRouter: (admin: AdminJS, auth: AuthenticationOptions, predefinedRouter?: express.Router | null, sessionOptions?: session.SessionOptions, formidableOptions?: FormidableOptions) => Router;
Directory Contents
Dirs: 1 × Files: 14