@catbee/utils
Version:
A modular, production-grade utility toolkit for Node.js and TypeScript, designed for robust, scalable applications (including Express-based services). All utilities are tree-shakable and can be imported independently.
89 lines (85 loc) • 3.43 kB
TypeScript
/*
* The MIT License
*
* Copyright (c) 2026 Catbee Technologies. https://catbee.in/license
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import { CatbeeConfig, CatbeeGlobalServerConfig } from '@catbee/utils/types';
import { Logger } from '@catbee/utils/logger';
/**
* Extends Express Request interface to add request ID tracking.
* Added by requestId middleware during request processing.
*/
declare global {
namespace Express {
interface Request {
/** Unique request identifier (set by middleware) */
id?: string;
/** Logger instance for the request (set by middleware) */
logger?: Logger;
/** User information (set by authentication middleware) */
user?: any;
}
}
}
/**
* Gets the global Catbee configuration.
*
* @returns The current Catbee configuration.
*/
declare function getCatbeeGlobalConfig(): CatbeeConfig;
/**
* Gets the global Catbee configuration.
*
* @deprecated Use `getCatbeeGlobalConfig` from `@catbee/utils/config` instead.
* @alias getCatbeeGlobalConfig
* @returns The current Catbee configuration.
*/
declare const getConfig: typeof getCatbeeGlobalConfig;
/**
* Sets the global Catbee configuration.
* Merges the provided partial configuration with the existing one.
*
* @param value - Partial Catbee configuration to set
*/
declare function setCatbeeGlobalConfig(value: Partial<CatbeeConfig>): void;
/**
* Sets the global Catbee configuration.
* Merges the provided partial configuration with the existing one.
*
* @deprecated Use `setCatbeeGlobalConfig` from `@catbee/utils/config` instead.
* @alias setCatbeeGlobalConfig
* @param value - Partial Catbee configuration to set
*/
declare const setConfig: typeof setCatbeeGlobalConfig;
/**
* Sets the global Catbee server configuration.
* Merges the provided partial server configuration with the existing one.
*
* @param value - Partial Catbee server configuration to set
*/
declare function setCatbeeServerGlobalConfig(value: Partial<CatbeeGlobalServerConfig>): void;
/**
* Gets the global Catbee server configuration.
*
* @returns The current Catbee server configuration.
*/
declare function getCatbeeServerGlobalConfig(): CatbeeGlobalServerConfig;
export { getCatbeeGlobalConfig, getCatbeeServerGlobalConfig, getConfig, setCatbeeGlobalConfig, setCatbeeServerGlobalConfig, setConfig };