UNPKG

@crowdin/app-project-module

Version:

Module that generates for you all common endpoints for serving standalone Crowdin App

35 lines (34 loc) 2.22 kB
import { Request, Response } from 'express'; import { Config, CrowdinClientRequest, ImagePath, UnauthorizedConfig } from '../types'; export declare class CodeError extends Error { code: number | undefined; constructor(message: string, code?: number); } export declare function extractBaseUrlFromRequest(req: Request): string; export declare function runAsyncWrapper(callback: Function): (req: Request | CrowdinClientRequest, res: Response, next: Function) => void; export declare function encryptData(config: Config, data: string): string; export declare function decryptData(config: Config, data: string): string; export declare function executeWithRetry<T>(func: () => Promise<T>, numOfRetries?: number): Promise<T>; export declare function getLogoUrl(config: Config | UnauthorizedConfig, moduleConfig?: ImagePath, modulePath?: string): string; /** * Logo middleware with backwards compatibility * Serves both /logo.png (backwards-compatible) and actual file name * @param config - App configuration (required for Cloudflare Workers Assets support) * @param moduleConfig - Module configuration with imagePath or imageUrl (optional, falls back to config.imagePath) * @returns Express middleware */ export declare function serveLogo(config: Config | UnauthorizedConfig, moduleConfig?: ImagePath): (req: Request, res: Response, next: Function) => Promise<void>; export declare function isAuthorizedConfig(config: Config | UnauthorizedConfig): config is Config; export declare function isJson(string: string): boolean; export declare function isDefined(value: any): boolean; export declare function isString(value: any): value is string; export declare function getPreviousDate(days: number): Date; export declare function prepareFormDataMetadataId(req: CrowdinClientRequest, config: Config): Promise<string>; export declare function validateEmail(email: string | number): boolean; export declare function getFormattedDate({ date, userTimezone }: { date: Date | number; userTimezone: string | undefined; }): string; export declare function kebabCase(str?: string): string; export declare function snakeCase(str?: string): string; export declare function uniqBy<T>(array: any, key: keyof T): T[];