UNPKG

lynx-framework

Version:

lynx is a NodeJS framework for Web Development, based on decorators and the async/await support.

119 lines (118 loc) 4.61 kB
import express from 'express'; import { MailClient } from './mail-client'; import Response from './response'; import UFS from './ufs'; export default interface Config { disabledDb: boolean; db: { type: string; host: string; port: number; username: string; password: string; database: string; entities: string[]; synchronize: boolean; logging: boolean; }; disabledGraphQL: boolean; publicFolders: string[]; viewFolders: string[]; translationFolders: string[]; middlewaresFolders: string[]; controllersFolders: string[]; migrationsFolders: string[]; templatingFolders: string[]; disableMigrations: boolean; sessionSecret: string; sessionStore?: any; tokenSecret: string; mailer: { sender: string; host: string; port: number; secure: boolean; auth: { user: string; pass: string; }; }; mailFactoryConstructor: () => MailClient; defaultLanguage: string; uploadPath: string; cachePath: string; jsonLimit?: string; ufs: UFS; onDatabaseInit: () => void; cachingImages: boolean; onlyModules: boolean; globalInterceptors: { cb: (req: express.Request, res: express.Response, next: () => void) => void; onlyFor?: string; }[]; beforePerformResponseInterceptors: ((res: Response, req: express.Request) => Response)[]; } export declare class ConfigBuilder { private config; /** * Create a new configuration builder * @param basePath the current base path of the application * @param legacyMode enable or disable the legacy mode (default: true) */ constructor(basePath: string, legacyMode?: boolean); setPublicFolders(folders: string[]): ConfigBuilder; setViewFolders(folders: string[]): ConfigBuilder; setTranslationFolders(folders: string[]): ConfigBuilder; setMiddlewaresFolders(folders: string[]): ConfigBuilder; setControllersFolders(folders: string[]): ConfigBuilder; setMigrationsFolders(folders: string[]): ConfigBuilder; setSessionSecret(secret: string): ConfigBuilder; setTokenSecret(secret: string): ConfigBuilder; setSessionStore(store: any): ConfigBuilder; setUploadPath(path: string): ConfigBuilder; setCachePath(path: string): ConfigBuilder; setDefaultLanguage(language: string): ConfigBuilder; setEntitiesFolders(folders: string[]): ConfigBuilder; setDatabaseType(type: string): ConfigBuilder; setDatabaseHost(host: string): ConfigBuilder; setDatabasePort(port: number): ConfigBuilder; setDatabaseLogin(username: string, password: string): ConfigBuilder; setDatabase(database: string): ConfigBuilder; disableDB(): ConfigBuilder; disableMigration(): ConfigBuilder; enableMigration(): ConfigBuilder; disableGraphQL(): ConfigBuilder; setMailerSender(address: string): ConfigBuilder; setMailerAuth(user: string, password: string): ConfigBuilder; setMailerServer(host: string, port: number, secure: boolean): ConfigBuilder; /** * Set a different method to istantiace a mailer client. * @param fn a function that istantiate a `MailClient` object */ setMailClientFactoryConstructor(fn: () => MailClient): this; setCustomUserEntity(hasCustom: boolean): ConfigBuilder; setJsonLimit(limit: string): ConfigBuilder; setUFS(ufs: UFS): ConfigBuilder; setOnDatabaseInit(cb: () => void): ConfigBuilder; enableCachingImages(): ConfigBuilder; /** * Add global interceptor to the Lynx application. * They are mounted before any other routes and middleware, using the * `express.use` methods. * @param cb The interceptor function that needs to be executed * @param onlyFor A sub-path for the interceptor (optional, default to anything) * @returns */ addGlobalRoutingInterceptor(cb: (req: express.Request, res: express.Response, next: () => void) => void, onlyFor?: string): ConfigBuilder; /** * Add "Response" interceptor to the Lynx application. * This interceptor will be executed when a request is completed, just before the * execution of the `performResponse` method of any response object. * * This method must return a (potentially) new response, or edit the current response * @param cb The interceptor function that needs to be executed * @returns */ addBeforePerformResponseInterceptor(cb: (res: Response, req: express.Request) => Response): ConfigBuilder; build(): Config; }