UNPKG

@azure-utils/storybooks

Version:

Utils to upload and manage Storybooks via Azure Functions and storage.

78 lines (77 loc) 2.58 kB
/** * Module exports a single function to register * the Storybooks management endpoints. * * @module */ import { type HttpFunctionOptions } from "@azure/functions"; import type { CheckPermissionsCallback, OpenAPIOptions } from "./utils/types"; export type { CheckPermissionsCallback, OpenAPIOptions }; /** * Options to register the storybooks router */ export type RegisterStorybooksRouterOptions = { /** * Name of the service. @default "storybooks" */ serviceName?: string; /** * Define the route on which all router is placed. * Can be a sub-path of the main API route. * * @default '' */ baseRoute?: string; /** * Set the Azure Functions authentication level for all routes. * * This is a good option to set if the service is used in * Headless mode and requires single token authentication * for all the requests. * * This setting does not affect health-check route. */ authLevel?: "admin"; /** * Name of the Environment variable which stores * the connection string to the Azure Storage resource. * @default 'AzureWebJobsStorage' */ storageConnectionStringEnvVar?: string; /** * Modify the cron-schedule of timer function * which purge outdated storybooks. * * Pass `null` to disable auto-purge functionality. * * @default "0 0 0 * * *" // Every midnight */ purgeScheduleCron?: string | null; /** * Options to configure OpenAPI schema */ openapi?: OpenAPIOptions; /** * Directories to serve static files from relative to project root (package.json) * @default './public' */ staticDirs?: string[]; /** * Callback function to check permissions. The function receives following params * @param permission - object containing resource and action to permit * @param context - Invocation context of Azure Function * @param request - the HTTP request object * * @return `true` to allow access, or following to deny: * - `false` - returns 403 response * - `HttpResponse` - returns the specified HTTP response */ checkPermissions?: CheckPermissionsCallback; }; /** * Function to register all routes required to manage the Storybooks including * GET, POST and DELETE methods. * * @returns a function to register additional HTTP handlers for the service. */ export declare function registerStorybooksRouter(options?: RegisterStorybooksRouterOptions): (name: string, options: HttpFunctionOptions) => void;