UNPKG

@zerooneit/expressive-tea

Version:
98 lines (97 loc) 3.7 kB
import { ExpressiveTeaServerProps } from '../libs/interfaces'; /** * Declare the properties which the server will save into settings, is a semi dynamic object since is allowed to save * any property but is contains only one defined property to keep the port of the server. * @typedef {Object} ExpressiveTeaServerProps * @property {number} [port] - Properties where server will be listen requests. * @summary Expressive Tea Server Properties */ /** * Settings Singleton Class to allow store server, application and plugins settings during design mode. Can be used on * run stage except by the port setting or any other in-design properties everything can be changed and reflected * immediatly, the fact that some of the properties will be ignored after design stage is because is used only one time * to provide initial settings or some initialization parameters. * * @class Settings * @param {ExpressiveTeaServerProps} [options={ port: 3000 }] * @summary Singleton Class to Store Server Settings */ declare class Settings { /** * Reset Singleton instance to the default values, all changes will be erased is not recommendable to use it * multiple times since all your options will be lost. Unless you have an option how to recover this is not * recommended to use often. Consider this is not DELETE initialization options, even if you deleted this is used * one time at the application starts. * * @static * @summary Reset Singleton instance * @memberof Settings */ static reset(): void; /** * Get Current Singleton Instance or Created if not exists. If a new instance is created it will created with default * options. * * @static * @returns {Settings} * @memberof Settings * @summary Get Singleton Instance. */ static getInstance(): Settings; /** * Singleton Instance only for internal. * * @private * @static * @type {Settings} * @memberof Settings */ private static instance; /** * Server configuration options. * * @private * @type {ExpressiveTeaServerProps} * @memberof Settings */ private options; constructor(options?: ExpressiveTeaServerProps); /** * It will return the latest snapshot options registered at the time that this method is called, as Expressive Tea * is designed as async methods some time options should not be available. * * @returns {ExpressiveTeaServerProps} * @memberof Settings * @summary Retrieve all registered options. */ getOptions(): ExpressiveTeaServerProps; /** * Retrieve the option as is designated on <settingName> parameter, if does not exist it will return null instead of * undefined to give them a value and data consistency. * * @param {string} settingName * @returns {*} * @memberof Settings * @summary Retrieve an option */ get(settingName: string): any; /** * Initialize or Edit a application options, this is only for in run options, as explained above initialization * options it won't affect any functionality as the application already started. * * @param {string} settingName * @param {*} value * @memberof Settings * @summary Initialize an option. */ set(settingName: string, value: any): void; /** * This Merge multiple options at the same time, this can edit or create the options. * * @param {ExpressiveTeaServerProps} [options={ port: 3000 }] * @memberof Settings * @summary Merge Options */ merge(options?: ExpressiveTeaServerProps): void; } export default Settings;