minauth
Version:
A TypeScript library for building authentication systems on top of the Mina blockchain and other zero-knowledge proofs solutions.
20 lines • 1.58 kB
JavaScript
import { pipe } from 'fp-ts/lib/function.js';
import * as RTE from 'fp-ts/lib/ReaderTaskEither.js';
import { tryCatchIO } from '../../utils/fp/readertaskeither.js';
/** Lift PluginRuntime action into PluginServer action. */
export const liftPluginRuntime = (a) => pipe(askPluginRuntimeEnv(), RTE.chain((pluginRuntimeEnv) => RTE.fromTaskEither(a(pluginRuntimeEnv))));
/** Use the instance of the underlying root logger. */
export const useRootLogger = (f) => pipe(RTE.asks(({ rootLogger }) => rootLogger), RTE.chain((rootLogger) => RTE.fromIO(() => f(rootLogger))));
/** Get the underlying root logger of the plugin server. */
export const askRootLogger = () => RTE.asks(({ rootLogger }) => rootLogger);
/** Get the underlying plugin runtime environment. */
export const askPluginRuntimeEnv = () => RTE.asks(({ pluginRuntimeEnv }) => pluginRuntimeEnv);
/** Use the instance of the underlying express app. */
export const useExpressApp = (f) => withExpressApp((expressApp) => tryCatchIO(() => f(expressApp), (err) => `error occurred while configuring express app: ${err}`));
/** Call an effectful (PluginServer monad) function on the underlying express app. */
export const withExpressApp = (f) => pipe(askExpressApp(), RTE.chain((expressApp) => f(expressApp)));
/** Get the underlying express app from the plugin server environment. */
export const askExpressApp = () => RTE.asks(({ expressApp }) => expressApp);
/** Get the plugin configuration from the plugin server environment. */
export const askConfig = () => RTE.asks(({ config }) => config);
//# sourceMappingURL=types.js.map