@tsdevstack/nest-common 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/auth/auth-user.interface.d.ts +62 -0
- package/dist/auth/auth.guard.d.ts +181 -0
- package/dist/auth/auth.guard.test.d.ts +1 -0
- package/dist/auth/auth.module.d.ts +45 -0
- package/dist/auth/index.d.ts +17 -0
- package/dist/auth/partner-api.decorator.d.ts +42 -0
- package/dist/auth/partner.decorator.d.ts +60 -0
- package/dist/auth/partner.decorator.test.d.ts +1 -0
- package/dist/auth/public.decorator.d.ts +42 -0
- package/dist/auth/public.decorator.test.d.ts +1 -0
- package/dist/auth/utils/extract-user-from-headers.d.ts +45 -0
- package/dist/auth/utils/extract-user-from-headers.test.d.ts +1 -0
- package/dist/auth/utils/index.d.ts +8 -0
- package/dist/auth/utils/parse-header-value.d.ts +40 -0
- package/dist/auth/utils/parse-header-value.test.d.ts +1 -0
- package/dist/auth/utils/to-camel-case.d.ts +18 -0
- package/dist/auth/utils/to-camel-case.test.d.ts +1 -0
- package/dist/bootstrap/create-app.d.ts +31 -0
- package/dist/bootstrap/create-app.test.d.ts +1 -0
- package/dist/bootstrap/start-worker.d.ts +24 -0
- package/dist/bootstrap/start-worker.test.d.ts +1 -0
- package/dist/bull/bull-config.module.d.ts +22 -0
- package/dist/bull/bull-config.module.test.d.ts +1 -0
- package/dist/bull/index.d.ts +1 -0
- package/dist/config/load-framework-config.d.ts +32 -0
- package/dist/config/load-framework-config.test.d.ts +1 -0
- package/dist/database/prisma-connection.d.ts +48 -0
- package/dist/database/prisma-connection.test.d.ts +1 -0
- package/dist/email-rate-limit/email-rate-limit.decorator.d.ts +8 -0
- package/dist/email-rate-limit/email-rate-limit.decorator.test.d.ts +1 -0
- package/dist/email-rate-limit/email-rate-limit.guard.d.ts +11 -0
- package/dist/email-rate-limit/email-rate-limit.guard.test.d.ts +1 -0
- package/dist/email-rate-limit/email-rate-limit.module.d.ts +2 -0
- package/dist/health/health.controller.d.ts +11 -0
- package/dist/health/health.controller.test.d.ts +1 -0
- package/dist/health/health.interface.d.ts +31 -0
- package/dist/health/health.module.d.ts +5 -0
- package/dist/health/health.service.d.ts +12 -0
- package/dist/health/health.service.test.d.ts +1 -0
- package/dist/health/index.d.ts +6 -0
- package/dist/health/indicators/memory.indicator.d.ts +7 -0
- package/dist/health/indicators/memory.indicator.test.d.ts +1 -0
- package/dist/health/indicators/redis.indicator.d.ts +7 -0
- package/dist/health/indicators/redis.indicator.test.d.ts +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +9 -0
- package/dist/index.mjs +9 -0
- package/dist/logging/index.d.ts +6 -0
- package/dist/logging/logger.interface.d.ts +29 -0
- package/dist/logging/logger.module.d.ts +14 -0
- package/dist/logging/logger.service.d.ts +31 -0
- package/dist/logging/logger.service.test.d.ts +1 -0
- package/dist/logging/logging.interceptor.d.ts +8 -0
- package/dist/logging/logging.interceptor.test.d.ts +1 -0
- package/dist/metrics/index.d.ts +5 -0
- package/dist/metrics/metrics.controller.d.ts +7 -0
- package/dist/metrics/metrics.controller.test.d.ts +1 -0
- package/dist/metrics/metrics.interceptor.d.ts +9 -0
- package/dist/metrics/metrics.interceptor.test.d.ts +1 -0
- package/dist/metrics/metrics.interface.d.ts +17 -0
- package/dist/metrics/metrics.module.d.ts +5 -0
- package/dist/metrics/metrics.service.d.ts +79 -0
- package/dist/metrics/metrics.service.test.d.ts +1 -0
- package/dist/notifications/index.d.ts +15 -0
- package/dist/notifications/interfaces/email-options.interface.d.ts +23 -0
- package/dist/notifications/interfaces/index.d.ts +6 -0
- package/dist/notifications/interfaces/push-options.interface.d.ts +16 -0
- package/dist/notifications/interfaces/sms-options.interface.d.ts +12 -0
- package/dist/notifications/notification.module.d.ts +2 -0
- package/dist/notifications/notification.module.test.d.ts +1 -0
- package/dist/notifications/notification.service.d.ts +28 -0
- package/dist/notifications/notification.service.test.d.ts +1 -0
- package/dist/notifications/providers/email/console.provider.d.ts +9 -0
- package/dist/notifications/providers/email/console.provider.test.d.ts +1 -0
- package/dist/notifications/providers/email/resend.provider.d.ts +24 -0
- package/dist/notifications/providers/email/resend.provider.test.d.ts +1 -0
- package/dist/notifications/providers/email-provider.interface.d.ts +17 -0
- package/dist/observability/index.d.ts +2 -0
- package/dist/observability/observability.interface.d.ts +32 -0
- package/dist/observability/observability.module.d.ts +24 -0
- package/dist/observability/observability.module.test.d.ts +1 -0
- package/dist/open-api-docs/create-swagger-document.d.ts +10 -0
- package/dist/open-api-docs/create-swagger-document.test.d.ts +1 -0
- package/dist/open-api-docs/generate-swagger-docs.d.ts +12 -0
- package/dist/open-api-docs/generate-swagger-docs.test.d.ts +1 -0
- package/dist/rate-limit/rate-limit-headers.interceptor.d.ts +5 -0
- package/dist/rate-limit/rate-limit-headers.interceptor.test.d.ts +1 -0
- package/dist/rate-limit/rate-limit.decorator.d.ts +11 -0
- package/dist/rate-limit/rate-limit.decorator.test.d.ts +1 -0
- package/dist/rate-limit/rate-limit.guard.d.ts +13 -0
- package/dist/rate-limit/rate-limit.guard.test.d.ts +1 -0
- package/dist/rate-limit/rate-limit.module.d.ts +2 -0
- package/dist/redis/redis.module.d.ts +2 -0
- package/dist/redis/redis.service.d.ts +17 -0
- package/dist/redis/redis.service.test.d.ts +1 -0
- package/dist/scheduler/index.d.ts +1 -0
- package/dist/scheduler/scheduler.guard.d.ts +73 -0
- package/dist/scheduler/scheduler.guard.test.d.ts +1 -0
- package/dist/secrets/index.d.ts +10 -0
- package/dist/secrets/providers/aws.provider.d.ts +56 -0
- package/dist/secrets/providers/aws.provider.test.d.ts +1 -0
- package/dist/secrets/providers/azure.provider.d.ts +70 -0
- package/dist/secrets/providers/azure.provider.test.d.ts +1 -0
- package/dist/secrets/providers/cloud-provider-adapter.d.ts +50 -0
- package/dist/secrets/providers/cloud-provider-adapter.test.d.ts +1 -0
- package/dist/secrets/providers/cloud-provider.interface.d.ts +86 -0
- package/dist/secrets/providers/gcp.provider.d.ts +64 -0
- package/dist/secrets/providers/gcp.provider.test.d.ts +1 -0
- package/dist/secrets/providers/local.provider.d.ts +82 -0
- package/dist/secrets/providers/local.provider.test.d.ts +1 -0
- package/dist/secrets/providers/provider-factory.d.ts +39 -0
- package/dist/secrets/providers/provider-factory.test.d.ts +1 -0
- package/dist/secrets/secrets.interface.d.ts +93 -0
- package/dist/secrets/secrets.module.d.ts +24 -0
- package/dist/secrets/secrets.service.d.ts +70 -0
- package/dist/secrets/secrets.service.test.d.ts +1 -0
- package/dist/service-client/base-service-client.d.ts +113 -0
- package/dist/service-client/base-service-client.test.d.ts +1 -0
- package/dist/service-client/filter-forward-headers.d.ts +11 -0
- package/dist/service-client/filter-forward-headers.test.d.ts +1 -0
- package/dist/telemetry/index.d.ts +4 -0
- package/dist/telemetry/telemetry.interface.d.ts +33 -0
- package/dist/telemetry/telemetry.module.d.ts +5 -0
- package/dist/telemetry/telemetry.service.d.ts +39 -0
- package/dist/telemetry/telemetry.service.test.d.ts +1 -0
- package/dist/telemetry/tracing.interceptor.d.ts +11 -0
- package/dist/telemetry/tracing.interceptor.test.d.ts +1 -0
- package/dist/utils/package-json.d.ts +25 -0
- package/package.json +102 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses header value to appropriate JavaScript type.
|
|
3
|
+
*
|
|
4
|
+
* Kong forwards all JWT claims as strings. This function intelligently
|
|
5
|
+
* parses them back to their original types:
|
|
6
|
+
* - Arrays: "USER,ADMIN" → ["USER", "ADMIN"]
|
|
7
|
+
* - Numbers: "123" → 123
|
|
8
|
+
* - Booleans: "true" → true, "false" → false
|
|
9
|
+
* - Strings: everything else
|
|
10
|
+
*
|
|
11
|
+
* @param value - String value from header
|
|
12
|
+
* @returns Parsed value in appropriate type
|
|
13
|
+
*
|
|
14
|
+
* @example Arrays
|
|
15
|
+
* ```typescript
|
|
16
|
+
* parseHeaderValue('USER,ADMIN') // ['USER', 'ADMIN']
|
|
17
|
+
* parseHeaderValue('read, write, delete') // ['read', 'write', 'delete']
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Numbers
|
|
21
|
+
* ```typescript
|
|
22
|
+
* parseHeaderValue('123') // 123
|
|
23
|
+
* parseHeaderValue('0') // 0
|
|
24
|
+
* parseHeaderValue('456789') // 456789
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example Booleans
|
|
28
|
+
* ```typescript
|
|
29
|
+
* parseHeaderValue('true') // true
|
|
30
|
+
* parseHeaderValue('false') // false
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example Strings
|
|
34
|
+
* ```typescript
|
|
35
|
+
* parseHeaderValue('john@example.com') // 'john@example.com'
|
|
36
|
+
* parseHeaderValue('Hello World') // 'Hello World'
|
|
37
|
+
* parseHeaderValue('123abc') // '123abc' (not pure number)
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseHeaderValue(value: string): string | string[] | number | boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts kebab-case to camelCase.
|
|
3
|
+
*
|
|
4
|
+
* Used to transform Kong header names (which use kebab-case) to
|
|
5
|
+
* JavaScript property names (which use camelCase).
|
|
6
|
+
*
|
|
7
|
+
* @param str - Kebab-case string (e.g., "tenant-id")
|
|
8
|
+
* @returns CamelCase string (e.g., "tenantId")
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* toCamelCase('tenant-id') // 'tenantId'
|
|
13
|
+
* toCamelCase('is-verified') // 'isVerified'
|
|
14
|
+
* toCamelCase('email') // 'email'
|
|
15
|
+
* toCamelCase('user-role-name') // 'userRoleName'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function toCamelCase(str: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { INestApplication, Type } from "@nestjs/common";
|
|
2
|
+
import { SwaggerConfig } from "../open-api-docs/create-swagger-document";
|
|
3
|
+
interface AppBootstrapOptions {
|
|
4
|
+
port: number | string;
|
|
5
|
+
globalPrefix: string;
|
|
6
|
+
jsonLimit?: number;
|
|
7
|
+
urlLimit?: number;
|
|
8
|
+
enableShutdownHooks?: boolean;
|
|
9
|
+
swagger: SwaggerConfig;
|
|
10
|
+
}
|
|
11
|
+
interface StartAppOptions {
|
|
12
|
+
swagger?: SwaggerConfig;
|
|
13
|
+
jsonLimit?: number;
|
|
14
|
+
urlLimit?: number;
|
|
15
|
+
enableShutdownHooks?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function createApp<T>(AppModule: Type<T>, options: AppBootstrapOptions): Promise<INestApplication>;
|
|
18
|
+
/**
|
|
19
|
+
* Load .env file if it exists (local development only)
|
|
20
|
+
*
|
|
21
|
+
* In local development, .env file is generated by the CLI and contains SECRETS_PROVIDER.
|
|
22
|
+
* In cloud/pipelines, platform sets environment variables directly (no .env file needed).
|
|
23
|
+
*
|
|
24
|
+
* Skips loading if SECRETS_PROVIDER is already set (cloud/pipeline environments).
|
|
25
|
+
* Walks up directory tree to find .env (similar to how .secrets.local.json is found).
|
|
26
|
+
* Silently ignores if .env doesn't exist - that's expected in cloud environments.
|
|
27
|
+
* Does NOT overwrite existing environment variables (platform vars take precedence).
|
|
28
|
+
*/
|
|
29
|
+
export declare function loadEnvIfExists(): void;
|
|
30
|
+
export declare function startApp<T>(AppModule: Type<T>, options?: StartAppOptions): Promise<void>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
interface StartWorkerOptions {
|
|
3
|
+
healthPort?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Bootstrap a worker process with standard configuration.
|
|
7
|
+
*
|
|
8
|
+
* Handles:
|
|
9
|
+
* 1. loadEnvIfExists() - loads root .env for SECRETS_PROVIDER
|
|
10
|
+
* 2. Sets SERVICE_NAME from package.json (required by SecretsModule)
|
|
11
|
+
* 3. Creates application context with the worker module
|
|
12
|
+
* 4. Health endpoint on configurable port (default :8080)
|
|
13
|
+
* 5. Graceful shutdown with 9s timeout
|
|
14
|
+
* 6. SIGTERM/SIGINT signal handlers
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // apps/auth-service/src/worker.ts
|
|
18
|
+
* import { startWorker } from '@tsdevstack/nest-common';
|
|
19
|
+
* import { WorkerModule } from './worker.module';
|
|
20
|
+
*
|
|
21
|
+
* startWorker(WorkerModule);
|
|
22
|
+
*/
|
|
23
|
+
export declare function startWorker<T>(WorkerModule: Type<T>, options?: StartWorkerOptions): Promise<void>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type DynamicModule } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* BullConfigModule
|
|
4
|
+
*
|
|
5
|
+
* Configures BullMQ with Redis connection from SecretsService.
|
|
6
|
+
* Portable across GCP/AWS/Azure/k8s - just needs Redis.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* @Module({
|
|
11
|
+
* imports: [
|
|
12
|
+
* BullConfigModule.forRoot(),
|
|
13
|
+
* BullModule.registerQueue({ name: 'email' }),
|
|
14
|
+
* ],
|
|
15
|
+
* providers: [EmailProcessor],
|
|
16
|
+
* })
|
|
17
|
+
* export class AppModule {}
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class BullConfigModule {
|
|
21
|
+
static forRoot(): DynamicModule;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BullConfigModule } from './bull-config.module';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework service configuration
|
|
3
|
+
* Loaded from .tsdevstack/config.json
|
|
4
|
+
*/
|
|
5
|
+
export interface FrameworkServiceConfig {
|
|
6
|
+
serviceName: string;
|
|
7
|
+
type: string;
|
|
8
|
+
port: number;
|
|
9
|
+
globalPrefix: string;
|
|
10
|
+
hasDatabase: boolean;
|
|
11
|
+
databaseType?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Load framework configuration for a specific service
|
|
15
|
+
*
|
|
16
|
+
* This function:
|
|
17
|
+
* 1. Finds .tsdevstack/config.json by walking up the directory tree
|
|
18
|
+
* 2. Parses and validates the JSON
|
|
19
|
+
* 3. Finds the service by name
|
|
20
|
+
* 4. Returns typed configuration object
|
|
21
|
+
*
|
|
22
|
+
* @param serviceName - The name of the service (e.g., 'auth-service')
|
|
23
|
+
* @returns Service configuration from framework config
|
|
24
|
+
* @throws Error if config file not found or service not found
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const config = loadFrameworkConfig('auth-service');
|
|
29
|
+
* // Returns: { serviceName: 'auth-service', port: 3001, ... }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadFrameworkConfig(serviceName: string): FrameworkServiceConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prisma Connection Manager
|
|
3
|
+
*
|
|
4
|
+
* Provides connection configuration for Prisma 7 with pg adapter.
|
|
5
|
+
* Prisma 7's "client" engine requires an adapter - pg Pool is used in all environments.
|
|
6
|
+
* Production uses DB_POOL_MAX for pool size, development defaults to 5 connections.
|
|
7
|
+
*/
|
|
8
|
+
import { Pool } from 'pg';
|
|
9
|
+
import { PrismaPg } from '@prisma/adapter-pg';
|
|
10
|
+
export interface PrismaConnectionConfig {
|
|
11
|
+
/** Prisma adapter (required for Prisma 7 client engine) */
|
|
12
|
+
adapter: PrismaPg;
|
|
13
|
+
}
|
|
14
|
+
export interface PrismaConnectionResult {
|
|
15
|
+
/** Config to pass to PrismaClient constructor */
|
|
16
|
+
config: PrismaConnectionConfig;
|
|
17
|
+
/** Pool instance - call pool.end() on shutdown */
|
|
18
|
+
pool: Pool;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create Prisma connection configuration with pg adapter.
|
|
22
|
+
*
|
|
23
|
+
* Prisma 7 with "client" engine requires an adapter, so pg Pool is used
|
|
24
|
+
* in all environments. Production requires DB_POOL_MAX, development
|
|
25
|
+
* defaults to 5 connections.
|
|
26
|
+
*
|
|
27
|
+
* @returns Configuration object and pool reference for cleanup
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { createPrismaConnection } from '@tsdevstack/nest-common';
|
|
32
|
+
* import { PrismaClient } from './generated/prisma';
|
|
33
|
+
*
|
|
34
|
+
* const { config, pool } = createPrismaConnection();
|
|
35
|
+
*
|
|
36
|
+
* class PrismaService extends PrismaClient {
|
|
37
|
+
* constructor() {
|
|
38
|
+
* super(config);
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* async onModuleDestroy() {
|
|
42
|
+
* await this.$disconnect();
|
|
43
|
+
* await pool.end();
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function createPrismaConnection(): PrismaConnectionResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface EmailRateLimitOptions {
|
|
2
|
+
windowMs?: number;
|
|
3
|
+
maxRequests?: number;
|
|
4
|
+
message?: string;
|
|
5
|
+
emailField?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const EMAIL_RATE_LIMIT_KEY = "emailRateLimit";
|
|
8
|
+
export declare const EmailRateLimitDecorator: (options: EmailRateLimitOptions) => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from "@nestjs/common";
|
|
2
|
+
import { Reflector } from "@nestjs/core";
|
|
3
|
+
import { RedisService } from "../redis/redis.service";
|
|
4
|
+
export declare class EmailRateLimitGuard implements CanActivate {
|
|
5
|
+
private readonly redisService;
|
|
6
|
+
private readonly reflector;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(redisService: RedisService, reflector: Reflector);
|
|
9
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
10
|
+
private checkEmailRateLimit;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HealthService } from './health.service';
|
|
2
|
+
import type { HealthCheckResult } from './health.interface';
|
|
3
|
+
export declare class HealthController {
|
|
4
|
+
private readonly healthService;
|
|
5
|
+
constructor(healthService: HealthService);
|
|
6
|
+
healthCheck(): Promise<HealthCheckResult>;
|
|
7
|
+
ping(): {
|
|
8
|
+
message: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface HealthIndicatorResult {
|
|
2
|
+
status: 'up' | 'down';
|
|
3
|
+
details?: Record<string, unknown>;
|
|
4
|
+
}
|
|
5
|
+
export interface HealthCheckResult {
|
|
6
|
+
status: 'ok' | 'degraded' | 'down';
|
|
7
|
+
timestamp: string;
|
|
8
|
+
uptime: number;
|
|
9
|
+
checks: Record<string, HealthIndicatorResult>;
|
|
10
|
+
memory: {
|
|
11
|
+
used: number;
|
|
12
|
+
total: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface HealthModuleOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Enable Redis health indicator
|
|
18
|
+
* Requires RedisModule to be imported
|
|
19
|
+
*/
|
|
20
|
+
redis?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Memory health indicator options
|
|
23
|
+
*/
|
|
24
|
+
memory?: {
|
|
25
|
+
/**
|
|
26
|
+
* Heap threshold in bytes. If exceeded, status becomes 'degraded'
|
|
27
|
+
* Default: 500MB (500 * 1024 * 1024)
|
|
28
|
+
*/
|
|
29
|
+
heapThreshold?: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import type { HealthCheckResult, HealthModuleOptions } from './health.interface';
|
|
3
|
+
import { RedisHealthIndicator } from './indicators/redis.indicator';
|
|
4
|
+
import { MemoryHealthIndicator } from './indicators/memory.indicator';
|
|
5
|
+
export declare class HealthService implements OnModuleInit {
|
|
6
|
+
private readonly options;
|
|
7
|
+
private readonly redisIndicator?;
|
|
8
|
+
private readonly memoryIndicator?;
|
|
9
|
+
constructor(options: HealthModuleOptions, redisIndicator?: RedisHealthIndicator | undefined, memoryIndicator?: MemoryHealthIndicator | undefined);
|
|
10
|
+
onModuleInit(): void;
|
|
11
|
+
check(): Promise<HealthCheckResult>;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { HealthModule } from './health.module';
|
|
2
|
+
export { HealthController } from './health.controller';
|
|
3
|
+
export { HealthService } from './health.service';
|
|
4
|
+
export { RedisHealthIndicator } from './indicators/redis.indicator';
|
|
5
|
+
export { MemoryHealthIndicator } from './indicators/memory.indicator';
|
|
6
|
+
export type { HealthModuleOptions, HealthCheckResult, HealthIndicatorResult, } from './health.interface';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RedisService } from '../../redis/redis.service';
|
|
2
|
+
import type { HealthIndicatorResult } from '../health.interface';
|
|
3
|
+
export declare class RedisHealthIndicator {
|
|
4
|
+
private readonly redisService;
|
|
5
|
+
constructor(redisService: RedisService);
|
|
6
|
+
check(): Promise<HealthIndicatorResult>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export { AuthModule } from './auth/auth.module';
|
|
2
|
+
export { AuthGuard } from './auth/auth.guard';
|
|
3
|
+
export { Public, IS_PUBLIC_KEY } from './auth/public.decorator';
|
|
4
|
+
export { PartnerApi, IS_PARTNER_API_KEY } from './auth/partner-api.decorator';
|
|
5
|
+
export { Partner } from './auth/partner.decorator';
|
|
6
|
+
export type { KongUser, AuthenticatedRequest } from './auth/auth-user.interface';
|
|
7
|
+
export { KongHeaders } from './auth/auth-user.interface';
|
|
8
|
+
export { RedisModule } from './redis/redis.module';
|
|
9
|
+
export { RedisService } from './redis/redis.service';
|
|
10
|
+
export { RateLimitModule } from './rate-limit/rate-limit.module';
|
|
11
|
+
export { RateLimitGuard } from './rate-limit/rate-limit.guard';
|
|
12
|
+
export { RateLimitDecorator } from './rate-limit/rate-limit.decorator';
|
|
13
|
+
export { RateLimitHeadersInterceptor } from './rate-limit/rate-limit-headers.interceptor';
|
|
14
|
+
export { RateLimitDecorator as RateLimit } from './rate-limit/rate-limit.decorator';
|
|
15
|
+
export { EmailRateLimitModule } from './email-rate-limit/email-rate-limit.module';
|
|
16
|
+
export { EmailRateLimitGuard } from './email-rate-limit/email-rate-limit.guard';
|
|
17
|
+
export { EmailRateLimitDecorator } from './email-rate-limit/email-rate-limit.decorator';
|
|
18
|
+
export { SecretsModule } from './secrets/secrets.module';
|
|
19
|
+
export { SecretsService } from './secrets/secrets.service';
|
|
20
|
+
export type { SecretsProvider, SecretsConfig, SecretsLoadResult } from './secrets/secrets.interface';
|
|
21
|
+
export { BaseServiceClient } from './service-client/base-service-client';
|
|
22
|
+
export type { ServiceClientConfig } from './service-client/base-service-client';
|
|
23
|
+
export { filterForwardHeaders } from './service-client/filter-forward-headers';
|
|
24
|
+
export { startApp, loadEnvIfExists } from './bootstrap/create-app';
|
|
25
|
+
export { startWorker } from './bootstrap/start-worker';
|
|
26
|
+
export { generateSwaggerDocs } from './open-api-docs/generate-swagger-docs';
|
|
27
|
+
export { ObservabilityModule } from './observability/observability.module';
|
|
28
|
+
export type { ObservabilityModuleOptions } from './observability/observability.interface';
|
|
29
|
+
export { LoggerService } from './logging/logger.service';
|
|
30
|
+
export type { LogContext } from './logging/logger.service';
|
|
31
|
+
export { MetricsService } from './metrics/metrics.service';
|
|
32
|
+
export { createPrismaConnection } from './database/prisma-connection';
|
|
33
|
+
export type { PrismaConnectionConfig, PrismaConnectionResult } from './database/prisma-connection';
|
|
34
|
+
export { NotificationModule } from './notifications/notification.module';
|
|
35
|
+
export { NotificationService } from './notifications/notification.service';
|
|
36
|
+
export type { EmailOptions } from './notifications/interfaces/email-options.interface';
|
|
37
|
+
export type { SMSOptions } from './notifications/interfaces/sms-options.interface';
|
|
38
|
+
export type { PushOptions } from './notifications/interfaces/push-options.interface';
|
|
39
|
+
export { BullConfigModule } from './bull/bull-config.module';
|
|
40
|
+
export { SchedulerGuard } from './scheduler/scheduler.guard';
|