@zerooneit/expressive-tea
Version:
A REST API over Express and Typescript
91 lines (90 loc) • 5.68 kB
TypeScript
import { Express } from 'express';
import { BOOT_STAGES } from '../libs/constants';
import { ExpressiveTeaServerProps, ExpressiveTeaStaticFileServer } from '../libs/interfaces';
/**
* Plug Class Decorator create a simple plugin to execute in one of the public stages defined on BOOT_STAGES, might
* be useful to attach a simple Express Server configuration.
*
* @decorator {ClassDecorator} Plug - Simple Plugin Decorator.
* @summary This Decorators is add plugin initialization to one of the selected stages.
* @param {ExpressiveTeaModuleProps} options
* @param {BOOT_STAGES} stage Boot Stage where the plugin should run or initialize.
* @param {string} name Plugin Name (recommended short names)
* @param {Function} method A Function to initialize the plugin, it will get a express application as argument.
* @param {boolean} required A Flag to let know if this is a hard requirement.
* @example
* {REPLACE-AT}Plug(BOOT_STAGES.BOOT_DEPENDENCIES, 'test', s => console.log, true)
* class Example extends Boot {}
*/
export declare function Plug(stage: BOOT_STAGES, name: string, method: (server?: Express | never, ...extraArgs: unknown[]) => Promise<any> | any, required?: boolean): (target: any) => void;
/**
* Since version 1.1.0 Expressive Tea allow to use external plugins using the node
* package @expressive-tea/plugin. This plugin engine allows to create more complex plugin configuration and provision
* since is allowing multi Boot Stage configuration and check other plugin dependencies.
*
* @decorator {ClassDecorator} Pour - Use Expressive Tea plugin definition instance.
* @summary Attach an Expressive Tea Definition Instance.
* @param Plugin - A Plugin Class which extends @expressive-tea/plugin/Plugin Class.
* @param pluginArgs - Plugin Constructor Arguments
* @version 1.1.0
* @link https://www.npmjs.com/package/@expressive-tea/plugin Expressive Tea Plugin
*/
export declare function Pour(Plugin: any, ...pluginArgs: any[]): (target: any) => void;
/**
* Server Settings Singleton Class Decorator this Provide the Configuration to the server or another component on
* the projects,is working as a container to store user and library settings.
* @decorator {ClassDecorator} ServerSettings - Declares Server Settings.
* @summary Declare Server Properties.
* @param {ExpressiveTeaModuleProps} options
* @param {object} [port=3000] Select Port Number where the server should be listening.
*/
export declare function ServerSettings(options?: ExpressiveTeaServerProps): (target: any) => any;
/**
* Create a new middleware function to serve files from within a given root directory. The file to serve will be
* determined by combining req.url with the provided root directory. When a file is not found, instead of sending a 404
* response, this module will instead call next() to move on to the next middleware, allowing for stacking
* and fall-backs. Check it out {@link https://expressjs.com/en/4x/api.html#express.static Express Static} to more
* information.
* @summary Static File Server
* @param {string} root - Root directory
* @param {string} [virtual=null] - Virtual Path
* @param {object} [options={}] - Static Server Options
* @decorator {ClassDecorator} Static - Create an Static mount static file server on root directory
* with virtual path if defined.
*/
export declare function Static(root: string, virtual?: string | null, options?: ExpressiveTeaStaticFileServer): (target: any) => void;
/**
* Set or Update Express application settings, and allow to change the behavior of the server where is listed on the
* next link {@link http://expressjs.com/en/4x/api.html#app.settings.table Express Settings} as this is using the same
* principle of app.set you should understand that is only apply the special settings mentioned above.
* @summary Express Setting Directive
* @param {string} name - Express Directive Setting Name
* @param {*} settings - Setting Arguments
* @decorator {ClassDecorator} ExpressDirecive - Set a Express App Setting.
*/
export declare function ExpressDirecive(name: string, ...settings: any[]): (target: any) => void;
/**
* Setting Property Decorator Automatically assign a settings declared on Settings Service into the decorated property.
* All properties will contains the settings value or undefined if current settings is not founded.
* @decorator {PropertyDecorator} Setting - Assign Server Settings to Property as default value.
* @summary Automatically assign a settings declared on the Server Settings decorator to a class property.
* @param {string} settingName The Setting name tha
*/
export declare function Setting(settingName: string): (target: any, propertyName: string) => any;
/**
* Register Module Method Decorator this Method Decorator is used at bootstrap level and should decorate the start
* method with a Module Class.
* @decorator {MethodDecorator} RegisterModule - Register a Expressive Tea module to application.
* @summary <b>ONLY</b> Decorate Start Method, this register the Module Classes created by the user.
* @param {Class} Module
*/
export declare function RegisterModule(Module: any): (target: any, property: any) => void;
export declare function Proxies(proxyContainers: any[]): (target: any) => void;
/**
* Register Modules Method Decorator this Method Decorator is used at bootstrap level and should decorate bootstrap class
* and register modules.
* @decorator {MethodDecorator} RegisterModule - Register a Expressive Tea module to application.
* @summary This register the Module Classes created by the user.
* @param Modules
*/
export declare function Modules(Modules: any[]): (target: any) => void;