@leanstacks/serverless-common
Version:
LeanStacks organization common serverless components.
47 lines (46 loc) • 1.62 kB
TypeScript
import Joi from 'joi';
/**
* The `BaseConfig` type describes the configuration values supplied to every AWS Lambda
* function by default. Extend `BaseConfig` with your own service-specific configuration
* type.
*
* Example:
* ```
* type ServiceConfig = BaseConfig & {
* FOO: string;
* BAR: number;
* }
* ```
*/
export type BaseConfig = {
AWS_EXECUTION_ENV: string;
AWS_LAMBDA_FUNCTION_NAME: string;
AWS_LAMBDA_FUNCTION_MEMORY_SIZE: string;
AWS_LAMBDA_FUNCTION_VERSION: string;
AWS_REGION: string;
LOGGING_ENABLED: boolean;
LOGGING_LEVEL: string;
};
/**
* Validates the configuration with the supplied Joi ObjectSchema. Uses `process.env` as the
* configuration source.
* @param schema - A `Joi.ObjectSchema` of type `TConfig` to validate the configuration values.
* @returns An Object of type `TConfig` containing the validated configuration if successful,
* otherwise throws a `ServiceError`.
* @throws Throws a `ServiceError` when validation is unsuccessful.
*/
declare function validateConfig<TConfig>(schema: Joi.ObjectSchema<TConfig>): TConfig;
/**
* A Joi ObjectSchema to validate the base AWS Lambda function configuration values.
*/
export declare const baseConfigSchema: Joi.ObjectSchema<any>;
/**
* A `BaseConfig` object containing the base AWS Lambda function configuration values.
* This is useful when your function does not have additional configuration attributes.
* @see {@link BaseConfig}
*/
export declare const baseConfigValues: BaseConfig;
declare const ConfigService: {
validateConfig: typeof validateConfig;
};
export default ConfigService;