@telia-ace/alliance-internal-node-utilities 1.0.4-next.1 → 1.0.4-next.3
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/CHANGELOG.md +13 -0
- package/dist/index.cjs +87 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -1
- package/dist/index.d.ts +80 -1
- package/dist/index.js +85 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -3,8 +3,10 @@ export { LoggerErrorInterceptor } from 'nestjs-pino';
|
|
|
3
3
|
import { ConfigService } from '@nestjs/config';
|
|
4
4
|
import { RequestHandler } from 'express';
|
|
5
5
|
import { ConfigParams, CookieConfigParams } from 'express-openid-connect';
|
|
6
|
+
import { z } from 'zod';
|
|
6
7
|
import { GraphQLError } from 'graphql';
|
|
7
8
|
import { HttpException, ExceptionFilter, ArgumentsHost, DynamicModule } from '@nestjs/common';
|
|
9
|
+
import { HealthIndicator, HealthIndicatorResult } from '@nestjs/terminus';
|
|
8
10
|
|
|
9
11
|
type Settings = {
|
|
10
12
|
baseURL?: ConfigParams['baseURL'];
|
|
@@ -38,15 +40,85 @@ declare function getPrivateKey(configService: ConfigService): string;
|
|
|
38
40
|
declare function createSystemUserToken(configService: ConfigService): string;
|
|
39
41
|
|
|
40
42
|
declare enum SharedConfigKeys {
|
|
43
|
+
/**
|
|
44
|
+
* Name for the cookie storing the user session
|
|
45
|
+
*
|
|
46
|
+
* Optional, defaults to "alliance-auth"
|
|
47
|
+
*/
|
|
41
48
|
AuthCookieName = "AUTH_COOKIE_NAME",
|
|
49
|
+
/**
|
|
50
|
+
* Secret to use when signing the user session cookie
|
|
51
|
+
*
|
|
52
|
+
* Optional, defaults to "zlLZBlk7wt8lypP5lA4D"
|
|
53
|
+
*/
|
|
42
54
|
AuthCookieSecret = "AUTH_COOKIE_SECRET",
|
|
55
|
+
/**
|
|
56
|
+
* Endpoint to use when communicating with the databases GraphQL API
|
|
57
|
+
*/
|
|
43
58
|
DbEndpoint = "DB_ENDPOINT",
|
|
59
|
+
/**
|
|
60
|
+
* Private key to use when signing JWT tokens
|
|
61
|
+
*
|
|
62
|
+
* Optional, defaults to "MIIEogIBAAKCAQEAsGqOzjnfQtCYlDqhgGAnKuJOCiPt2WpCmL1Cs+SLBQlyoNn6LT8BJ6ZRj8t/vK8Sw0p51Uq/3k0tazh7bLGkWNMBLY3BqFiNRMMnCqHJfvGIUi/itNXNe2kbP7H3rbyQTu4O7yH/ZAMitdpF2KLucVRlFxrQ/ggZjxwEGso4JUnCwmAnoKct/uupKz9Y2PMTr00WWN79aPfD4LcKi570VJqBT3ISSucdwFLYNqnOkQnEa8O8xbthQhiI0k1GGJT+GCQcATUPeEbaCFXonOrJm+CyuMmQWYLFF3NbE5NllU1jz9PYHzp2hAgAx8WGeretTvpEA1dE2gvXNESGbQ8FxQIDAQABAoIBAAjTJmud1348eGAfLV8CRaij2MAxxenJ9/ozVXfcPIa2+fCelsuBSv8pwbYODvNoVT7xpcs2nwccGI6JgnBl09EhqlMWCT7w7GLT2aBy3A/T6JF76xJICQGzDfWPYygMtlyhv0YqZDUjjFlJHun+/ysqIUMY81AR0FLUAEc6yw41ChcdSvTgIqBM9f5PsBRK7zOgdW1vcVQiZbf2Vqr+7wTJ+6b9A4rWnnAqesGDXqYupx3UJEu3x0wRNQB8FeiG9iJrw4cyD9SmM95doTyKosQ2PWWnUO1NMgmWCR/mWcKZAUcfZUpnQ8rz75WAWept8ZIOOdha8UZ1B/kw3EsVdEECgYEA3iN0BRUqMN0J69bazvlNOWtI+Chc1lYMt/tZ4p78pIJpAZvc3rQ9lAp6JvOEno2IglULA4I+ZLUmpz+lfu7XxKMNOI3cnG7WdiGbiIlwOSwuxzeO1FJqhtnc0U6mNkIjptV8b2etj8U2/SXAC3CC8XgsawAj9A/I7awlCL3NXdECgYEAy07gun3rcd3Y0ISmd3+SbAn/MbGf8uRLcfSc2ls9B6m3pXj25prXJWIrB6DyGuL/HQmHzffQkOeXmwFGHFXyiIFOIITX4z8b9lMnavgUZoPDY+ZFsxp6I7vMn75AetB8wYXpOFFeCG/Ck/VSIYP7oAN8kLw8EHdOuNbZYbu34bUCgYBYd14ZOBiZZS4yUlrJ2tc6atOgoNJ4OcTO8LcXXaHYEmenUF9iAf4UGygSoyDJ1CvtW9kLCK+4g7xlFx/dsVkU4qq9PyIA2tNmMHQ0qCedXU8z35huTnRGSDV81gmzyhtQsezgoTWp8Cy6HHKjG6fKasWlx2SKKk8m+Eu3c396QQKBgBMY2asq4M7VU+RiUXCwHwTe+4Wjda7PGvcdTw6Du3vYyVNVxXtr2AG+8uPIjnVQFT6ZApSqToEOAAOjXv6SZDHGU5xiXhUOfIXq0a0OmHv4rIXZv3pPZmGs5k+rA0uGAfH7riiIHBkWxmQ3ivty9lPVgAHobIvvaQmbxNeVVnRxAoGAUzUmcBiUAiODfjulrpYvWG0tCn5B//yk7g1Tm3Chrh9huA1qGEN3jDoqSsTd5k4Yi5foyAZt5ORgoiUVm4IsfS56aoxIco1CtFG3zeMQRy4uKzTsvUTOdsJ4RlQdjNwpngXR44VL0WelgCDqTqJwn5ubzPvuIHuTj3cBpmJCjOo="
|
|
63
|
+
*/
|
|
44
64
|
JwtPrivateKey = "JWT_PRIVATE_KEY",
|
|
65
|
+
/**
|
|
66
|
+
* Log level to output
|
|
67
|
+
*
|
|
68
|
+
* Supports "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace"
|
|
69
|
+
*
|
|
70
|
+
* Optional, defaults to "trace"
|
|
71
|
+
*/
|
|
45
72
|
ServiceLogLevel = "SERVICE_LOG_LEVEL",
|
|
73
|
+
/**
|
|
74
|
+
* Port to run the service on.
|
|
75
|
+
*
|
|
76
|
+
* Optional, defaults to "3000"
|
|
77
|
+
*/
|
|
46
78
|
ServicePort = "SERVICE_PORT",
|
|
79
|
+
/**
|
|
80
|
+
* Url to redis server to use when storing / reading user session information.
|
|
81
|
+
*
|
|
82
|
+
* Optional
|
|
83
|
+
*/
|
|
47
84
|
RedisHost = "REDIS_HOST",
|
|
85
|
+
/**
|
|
86
|
+
* Password to redis server to use when storing / reading user session information.
|
|
87
|
+
*
|
|
88
|
+
* Optional
|
|
89
|
+
*/
|
|
48
90
|
RedisPassword = "REDIS_PASSWORD"
|
|
49
91
|
}
|
|
92
|
+
declare const zBooleanEnum: z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">;
|
|
93
|
+
declare const zNonEmptyString: z.ZodString;
|
|
94
|
+
declare const zSharedConfig: z.ZodObject<{
|
|
95
|
+
AUTH_COOKIE_NAME: z.ZodDefault<z.ZodString>;
|
|
96
|
+
AUTH_COOKIE_SECRET: z.ZodDefault<z.ZodString>;
|
|
97
|
+
DB_ENDPOINT: z.ZodString;
|
|
98
|
+
JWT_PRIVATE_KEY: z.ZodDefault<z.ZodString>;
|
|
99
|
+
SERVICE_LOG_LEVEL: z.ZodDefault<z.ZodEnum<["silent", "fatal", "error", "warn", "info", "debug", "trace"]>>;
|
|
100
|
+
SERVICE_PORT: z.ZodDefault<z.ZodEffects<z.ZodString, number, string>>;
|
|
101
|
+
REDIS_HOST: z.ZodOptional<z.ZodString>;
|
|
102
|
+
REDIS_PASSWORD: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
AUTH_COOKIE_NAME: string;
|
|
105
|
+
AUTH_COOKIE_SECRET: string;
|
|
106
|
+
DB_ENDPOINT: string;
|
|
107
|
+
JWT_PRIVATE_KEY: string;
|
|
108
|
+
SERVICE_LOG_LEVEL: "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace";
|
|
109
|
+
SERVICE_PORT: number;
|
|
110
|
+
REDIS_HOST?: string | undefined;
|
|
111
|
+
REDIS_PASSWORD?: string | undefined;
|
|
112
|
+
}, {
|
|
113
|
+
DB_ENDPOINT: string;
|
|
114
|
+
AUTH_COOKIE_NAME?: string | undefined;
|
|
115
|
+
AUTH_COOKIE_SECRET?: string | undefined;
|
|
116
|
+
JWT_PRIVATE_KEY?: string | undefined;
|
|
117
|
+
SERVICE_LOG_LEVEL?: "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace" | undefined;
|
|
118
|
+
SERVICE_PORT?: string | undefined;
|
|
119
|
+
REDIS_HOST?: string | undefined;
|
|
120
|
+
REDIS_PASSWORD?: string | undefined;
|
|
121
|
+
}>;
|
|
50
122
|
|
|
51
123
|
declare enum AllianceHeaders {
|
|
52
124
|
TargetUrl = "alliance-target-url",
|
|
@@ -103,6 +175,13 @@ type LooseObject = Record<string, any>;
|
|
|
103
175
|
|
|
104
176
|
declare function getAppManifests(apps: string[]): Promise<LooseObject[]>;
|
|
105
177
|
|
|
178
|
+
declare class RedisHealthIndicator extends HealthIndicator {
|
|
179
|
+
private configService;
|
|
180
|
+
constructor(configService: ConfigService);
|
|
181
|
+
isHealthy(): Promise<HealthIndicatorResult>;
|
|
182
|
+
private getRedisClient;
|
|
183
|
+
}
|
|
184
|
+
|
|
106
185
|
type ModuleSettings = {
|
|
107
186
|
logLevel?: string;
|
|
108
187
|
redact?: boolean;
|
|
@@ -125,4 +204,4 @@ declare class LoggerService {
|
|
|
125
204
|
|
|
126
205
|
declare function slugify(name: string): string;
|
|
127
206
|
|
|
128
|
-
export { AllianceException, AllianceExceptionFilter, AllianceGqlException, AllianceHeaders, DatabasesErrorCodes, GatewayErrorCodes, LoggerModule, LoggerService, PortalErrorCodes, SharedConfigKeys, authMiddleware, createBearerToken, createPublicDistributionFiles, createSystemUserToken, getAppManifests, getPrivateKey, slugify };
|
|
207
|
+
export { AllianceException, AllianceExceptionFilter, AllianceGqlException, AllianceHeaders, DatabasesErrorCodes, GatewayErrorCodes, LoggerModule, LoggerService, PortalErrorCodes, RedisHealthIndicator, SharedConfigKeys, authMiddleware, createBearerToken, createPublicDistributionFiles, createSystemUserToken, getAppManifests, getPrivateKey, slugify, zBooleanEnum, zNonEmptyString, zSharedConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ export { LoggerErrorInterceptor } from 'nestjs-pino';
|
|
|
3
3
|
import { ConfigService } from '@nestjs/config';
|
|
4
4
|
import { RequestHandler } from 'express';
|
|
5
5
|
import { ConfigParams, CookieConfigParams } from 'express-openid-connect';
|
|
6
|
+
import { z } from 'zod';
|
|
6
7
|
import { GraphQLError } from 'graphql';
|
|
7
8
|
import { HttpException, ExceptionFilter, ArgumentsHost, DynamicModule } from '@nestjs/common';
|
|
9
|
+
import { HealthIndicator, HealthIndicatorResult } from '@nestjs/terminus';
|
|
8
10
|
|
|
9
11
|
type Settings = {
|
|
10
12
|
baseURL?: ConfigParams['baseURL'];
|
|
@@ -38,15 +40,85 @@ declare function getPrivateKey(configService: ConfigService): string;
|
|
|
38
40
|
declare function createSystemUserToken(configService: ConfigService): string;
|
|
39
41
|
|
|
40
42
|
declare enum SharedConfigKeys {
|
|
43
|
+
/**
|
|
44
|
+
* Name for the cookie storing the user session
|
|
45
|
+
*
|
|
46
|
+
* Optional, defaults to "alliance-auth"
|
|
47
|
+
*/
|
|
41
48
|
AuthCookieName = "AUTH_COOKIE_NAME",
|
|
49
|
+
/**
|
|
50
|
+
* Secret to use when signing the user session cookie
|
|
51
|
+
*
|
|
52
|
+
* Optional, defaults to "zlLZBlk7wt8lypP5lA4D"
|
|
53
|
+
*/
|
|
42
54
|
AuthCookieSecret = "AUTH_COOKIE_SECRET",
|
|
55
|
+
/**
|
|
56
|
+
* Endpoint to use when communicating with the databases GraphQL API
|
|
57
|
+
*/
|
|
43
58
|
DbEndpoint = "DB_ENDPOINT",
|
|
59
|
+
/**
|
|
60
|
+
* Private key to use when signing JWT tokens
|
|
61
|
+
*
|
|
62
|
+
* Optional, defaults to "MIIEogIBAAKCAQEAsGqOzjnfQtCYlDqhgGAnKuJOCiPt2WpCmL1Cs+SLBQlyoNn6LT8BJ6ZRj8t/vK8Sw0p51Uq/3k0tazh7bLGkWNMBLY3BqFiNRMMnCqHJf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sezgoTWp8Cy6HHKjG6fKasWlx2SKKk8m+Eu3c396QQKBgBMY2asq4M7VU+RiUXCwHwTe+4Wjda7PGvcdTw6Du3vYyVNVxXtr2AG+8uPIjnVQFT6ZApSqToEOAAOjXv6SZDHGU5xiXhUOfIXq0a0OmHv4rIXZv3pPZmGs5k+rA0uGAfH7riiIHBkWxmQ3ivty9lPVgAHobIvvaQmbxNeVVnRxAoGAUzUmcBiUAiODfjulrpYvWG0tCn5B//yk7g1Tm3Chrh9huA1qGEN3jDoqSsTd5k4Yi5foyAZt5ORgoiUVm4IsfS56aoxIco1CtFG3zeMQRy4uKzTsvUTOdsJ4RlQdjNwpngXR44VL0WelgCDqTqJwn5ubzPvuIHuTj3cBpmJCjOo="
|
|
63
|
+
*/
|
|
44
64
|
JwtPrivateKey = "JWT_PRIVATE_KEY",
|
|
65
|
+
/**
|
|
66
|
+
* Log level to output
|
|
67
|
+
*
|
|
68
|
+
* Supports "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace"
|
|
69
|
+
*
|
|
70
|
+
* Optional, defaults to "trace"
|
|
71
|
+
*/
|
|
45
72
|
ServiceLogLevel = "SERVICE_LOG_LEVEL",
|
|
73
|
+
/**
|
|
74
|
+
* Port to run the service on.
|
|
75
|
+
*
|
|
76
|
+
* Optional, defaults to "3000"
|
|
77
|
+
*/
|
|
46
78
|
ServicePort = "SERVICE_PORT",
|
|
79
|
+
/**
|
|
80
|
+
* Url to redis server to use when storing / reading user session information.
|
|
81
|
+
*
|
|
82
|
+
* Optional
|
|
83
|
+
*/
|
|
47
84
|
RedisHost = "REDIS_HOST",
|
|
85
|
+
/**
|
|
86
|
+
* Password to redis server to use when storing / reading user session information.
|
|
87
|
+
*
|
|
88
|
+
* Optional
|
|
89
|
+
*/
|
|
48
90
|
RedisPassword = "REDIS_PASSWORD"
|
|
49
91
|
}
|
|
92
|
+
declare const zBooleanEnum: z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">;
|
|
93
|
+
declare const zNonEmptyString: z.ZodString;
|
|
94
|
+
declare const zSharedConfig: z.ZodObject<{
|
|
95
|
+
AUTH_COOKIE_NAME: z.ZodDefault<z.ZodString>;
|
|
96
|
+
AUTH_COOKIE_SECRET: z.ZodDefault<z.ZodString>;
|
|
97
|
+
DB_ENDPOINT: z.ZodString;
|
|
98
|
+
JWT_PRIVATE_KEY: z.ZodDefault<z.ZodString>;
|
|
99
|
+
SERVICE_LOG_LEVEL: z.ZodDefault<z.ZodEnum<["silent", "fatal", "error", "warn", "info", "debug", "trace"]>>;
|
|
100
|
+
SERVICE_PORT: z.ZodDefault<z.ZodEffects<z.ZodString, number, string>>;
|
|
101
|
+
REDIS_HOST: z.ZodOptional<z.ZodString>;
|
|
102
|
+
REDIS_PASSWORD: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
AUTH_COOKIE_NAME: string;
|
|
105
|
+
AUTH_COOKIE_SECRET: string;
|
|
106
|
+
DB_ENDPOINT: string;
|
|
107
|
+
JWT_PRIVATE_KEY: string;
|
|
108
|
+
SERVICE_LOG_LEVEL: "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace";
|
|
109
|
+
SERVICE_PORT: number;
|
|
110
|
+
REDIS_HOST?: string | undefined;
|
|
111
|
+
REDIS_PASSWORD?: string | undefined;
|
|
112
|
+
}, {
|
|
113
|
+
DB_ENDPOINT: string;
|
|
114
|
+
AUTH_COOKIE_NAME?: string | undefined;
|
|
115
|
+
AUTH_COOKIE_SECRET?: string | undefined;
|
|
116
|
+
JWT_PRIVATE_KEY?: string | undefined;
|
|
117
|
+
SERVICE_LOG_LEVEL?: "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace" | undefined;
|
|
118
|
+
SERVICE_PORT?: string | undefined;
|
|
119
|
+
REDIS_HOST?: string | undefined;
|
|
120
|
+
REDIS_PASSWORD?: string | undefined;
|
|
121
|
+
}>;
|
|
50
122
|
|
|
51
123
|
declare enum AllianceHeaders {
|
|
52
124
|
TargetUrl = "alliance-target-url",
|
|
@@ -103,6 +175,13 @@ type LooseObject = Record<string, any>;
|
|
|
103
175
|
|
|
104
176
|
declare function getAppManifests(apps: string[]): Promise<LooseObject[]>;
|
|
105
177
|
|
|
178
|
+
declare class RedisHealthIndicator extends HealthIndicator {
|
|
179
|
+
private configService;
|
|
180
|
+
constructor(configService: ConfigService);
|
|
181
|
+
isHealthy(): Promise<HealthIndicatorResult>;
|
|
182
|
+
private getRedisClient;
|
|
183
|
+
}
|
|
184
|
+
|
|
106
185
|
type ModuleSettings = {
|
|
107
186
|
logLevel?: string;
|
|
108
187
|
redact?: boolean;
|
|
@@ -125,4 +204,4 @@ declare class LoggerService {
|
|
|
125
204
|
|
|
126
205
|
declare function slugify(name: string): string;
|
|
127
206
|
|
|
128
|
-
export { AllianceException, AllianceExceptionFilter, AllianceGqlException, AllianceHeaders, DatabasesErrorCodes, GatewayErrorCodes, LoggerModule, LoggerService, PortalErrorCodes, SharedConfigKeys, authMiddleware, createBearerToken, createPublicDistributionFiles, createSystemUserToken, getAppManifests, getPrivateKey, slugify };
|
|
207
|
+
export { AllianceException, AllianceExceptionFilter, AllianceGqlException, AllianceHeaders, DatabasesErrorCodes, GatewayErrorCodes, LoggerModule, LoggerService, PortalErrorCodes, RedisHealthIndicator, SharedConfigKeys, authMiddleware, createBearerToken, createPublicDistributionFiles, createSystemUserToken, getAppManifests, getPrivateKey, slugify, zBooleanEnum, zNonEmptyString, zSharedConfig };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { LoggerErrorInterceptor } from 'nestjs-pino';
|
|
|
3
3
|
import { Store } from 'express-session';
|
|
4
4
|
import { auth } from 'express-openid-connect';
|
|
5
5
|
import { createClient } from 'redis';
|
|
6
|
+
import { z } from 'zod';
|
|
6
7
|
import { sign } from 'jsonwebtoken';
|
|
7
8
|
import { validate } from 'jsonschema';
|
|
8
9
|
import { existsSync, mkdirSync, writeFileSync, readFileSync, rmSync } from 'node:fs';
|
|
@@ -10,6 +11,7 @@ import { resolve } from 'node:path';
|
|
|
10
11
|
import { GraphQLError } from 'graphql';
|
|
11
12
|
import { HttpStatus, HttpException, Catch, Injectable, Module } from '@nestjs/common';
|
|
12
13
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
14
|
+
import { HealthIndicator } from '@nestjs/terminus';
|
|
13
15
|
import _slugify from 'slugify';
|
|
14
16
|
|
|
15
17
|
var __defProp = Object.defineProperty;
|
|
@@ -187,8 +189,6 @@ var RedisStore = class RedisStore2 extends Store {
|
|
|
187
189
|
}
|
|
188
190
|
};
|
|
189
191
|
var esm_default = RedisStore;
|
|
190
|
-
|
|
191
|
-
// src/constants/config.ts
|
|
192
192
|
var SharedConfigKeys;
|
|
193
193
|
(function(SharedConfigKeys2) {
|
|
194
194
|
SharedConfigKeys2["AuthCookieName"] = "AUTH_COOKIE_NAME";
|
|
@@ -200,6 +200,29 @@ var SharedConfigKeys;
|
|
|
200
200
|
SharedConfigKeys2["RedisHost"] = "REDIS_HOST";
|
|
201
201
|
SharedConfigKeys2["RedisPassword"] = "REDIS_PASSWORD";
|
|
202
202
|
})(SharedConfigKeys || (SharedConfigKeys = {}));
|
|
203
|
+
var zBooleanEnum = z.enum([
|
|
204
|
+
"true",
|
|
205
|
+
"false"
|
|
206
|
+
]).transform((strBool) => strBool === "true");
|
|
207
|
+
var zNonEmptyString = z.string().min(1);
|
|
208
|
+
var zSharedConfig = z.object({
|
|
209
|
+
["AUTH_COOKIE_NAME"]: zNonEmptyString.default("alliance-auth"),
|
|
210
|
+
["AUTH_COOKIE_SECRET"]: zNonEmptyString.default("zlLZBlk7wt8lypP5lA4D"),
|
|
211
|
+
["DB_ENDPOINT"]: zNonEmptyString,
|
|
212
|
+
["JWT_PRIVATE_KEY"]: zNonEmptyString.default("MIIEogIBAAKCAQEAsGqOzjnfQtCYlDqhgGAnKuJOCiPt2WpCmL1Cs+SLBQlyoNn6LT8BJ6ZRj8t/vK8Sw0p51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yIA2tNmMHQ0qCedXU8z35huTnRGSDV81gmzyhtQsezgoTWp8Cy6HHKjG6fKasWlx2SKKk8m+Eu3c396QQKBgBMY2asq4M7VU+RiUXCwHwTe+4Wjda7PGvcdTw6Du3vYyVNVxXtr2AG+8uPIjnVQFT6ZApSqToEOAAOjXv6SZDHGU5xiXhUOfIXq0a0OmHv4rIXZv3pPZmGs5k+rA0uGAfH7riiIHBkWxmQ3ivty9lPVgAHobIvvaQmbxNeVVnRxAoGAUzUmcBiUAiODfjulrpYvWG0tCn5B//yk7g1Tm3Chrh9huA1qGEN3jDoqSsTd5k4Yi5foyAZt5ORgoiUVm4IsfS56aoxIco1CtFG3zeMQRy4uKzTsvUTOdsJ4RlQdjNwpngXR44VL0WelgCDqTqJwn5ubzPvuIHuTj3cBpmJCjOo="),
|
|
213
|
+
["SERVICE_LOG_LEVEL"]: z.enum([
|
|
214
|
+
"silent",
|
|
215
|
+
"fatal",
|
|
216
|
+
"error",
|
|
217
|
+
"warn",
|
|
218
|
+
"info",
|
|
219
|
+
"debug",
|
|
220
|
+
"trace"
|
|
221
|
+
]).default("trace"),
|
|
222
|
+
["SERVICE_PORT"]: zNonEmptyString.transform(Number).default("3000"),
|
|
223
|
+
["REDIS_HOST"]: zNonEmptyString.optional(),
|
|
224
|
+
["REDIS_PASSWORD"]: zNonEmptyString.optional()
|
|
225
|
+
});
|
|
203
226
|
|
|
204
227
|
// src/constants/headers.ts
|
|
205
228
|
var AllianceHeaders;
|
|
@@ -894,6 +917,56 @@ function _ts_metadata(k, v) {
|
|
|
894
917
|
return Reflect.metadata(k, v);
|
|
895
918
|
}
|
|
896
919
|
__name(_ts_metadata, "_ts_metadata");
|
|
920
|
+
var RedisHealthIndicator = class RedisHealthIndicator2 extends HealthIndicator {
|
|
921
|
+
static {
|
|
922
|
+
__name(this, "RedisHealthIndicator");
|
|
923
|
+
}
|
|
924
|
+
configService;
|
|
925
|
+
constructor(configService) {
|
|
926
|
+
super();
|
|
927
|
+
this.configService = configService;
|
|
928
|
+
}
|
|
929
|
+
async isHealthy() {
|
|
930
|
+
try {
|
|
931
|
+
const client = await this.getRedisClient();
|
|
932
|
+
await client.ping();
|
|
933
|
+
} catch {
|
|
934
|
+
return this.getStatus("redis", false);
|
|
935
|
+
}
|
|
936
|
+
return this.getStatus("redis", true);
|
|
937
|
+
}
|
|
938
|
+
async getRedisClient() {
|
|
939
|
+
const redisClient = createClient({
|
|
940
|
+
url: this.configService.getOrThrow(SharedConfigKeys.RedisHost),
|
|
941
|
+
password: this.configService.get(SharedConfigKeys.RedisPassword)
|
|
942
|
+
});
|
|
943
|
+
await redisClient.connect();
|
|
944
|
+
return redisClient;
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
RedisHealthIndicator = _ts_decorate2([
|
|
948
|
+
Injectable(),
|
|
949
|
+
_ts_metadata("design:type", Function),
|
|
950
|
+
_ts_metadata("design:paramtypes", [
|
|
951
|
+
typeof ConfigService === "undefined" ? Object : ConfigService
|
|
952
|
+
])
|
|
953
|
+
], RedisHealthIndicator);
|
|
954
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
955
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
956
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
957
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
958
|
+
else
|
|
959
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
960
|
+
if (d = decorators[i])
|
|
961
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
962
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
963
|
+
}
|
|
964
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
965
|
+
function _ts_metadata2(k, v) {
|
|
966
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
967
|
+
return Reflect.metadata(k, v);
|
|
968
|
+
}
|
|
969
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
897
970
|
function _ts_param(paramIndex, decorator) {
|
|
898
971
|
return function(target, key) {
|
|
899
972
|
decorator(target, key, paramIndex);
|
|
@@ -923,17 +996,17 @@ var LoggerService = class LoggerService2 {
|
|
|
923
996
|
error;
|
|
924
997
|
fatal;
|
|
925
998
|
};
|
|
926
|
-
LoggerService =
|
|
999
|
+
LoggerService = _ts_decorate3([
|
|
927
1000
|
Injectable(),
|
|
928
1001
|
_ts_param(0, InjectPinoLogger()),
|
|
929
|
-
|
|
930
|
-
|
|
1002
|
+
_ts_metadata2("design:type", Function),
|
|
1003
|
+
_ts_metadata2("design:paramtypes", [
|
|
931
1004
|
typeof PinoLogger === "undefined" ? Object : PinoLogger
|
|
932
1005
|
])
|
|
933
1006
|
], LoggerService);
|
|
934
1007
|
|
|
935
1008
|
// src/logging/logging.module.ts
|
|
936
|
-
function
|
|
1009
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
937
1010
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
938
1011
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
939
1012
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -943,7 +1016,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
943
1016
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
944
1017
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
945
1018
|
}
|
|
946
|
-
__name(
|
|
1019
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
947
1020
|
var LoggerModule = class LoggerModule2 {
|
|
948
1021
|
static {
|
|
949
1022
|
__name(this, "LoggerModule");
|
|
@@ -967,7 +1040,9 @@ var LoggerModule = class LoggerModule2 {
|
|
|
967
1040
|
"authorization",
|
|
968
1041
|
"headers.authorization",
|
|
969
1042
|
"req.headers.authorization",
|
|
970
|
-
"res.headers.authorization"
|
|
1043
|
+
"res.headers.authorization",
|
|
1044
|
+
"req.headers.cookie",
|
|
1045
|
+
'res.headers["set-cookie"]'
|
|
971
1046
|
] : []
|
|
972
1047
|
}
|
|
973
1048
|
})
|
|
@@ -981,7 +1056,7 @@ var LoggerModule = class LoggerModule2 {
|
|
|
981
1056
|
};
|
|
982
1057
|
}
|
|
983
1058
|
};
|
|
984
|
-
LoggerModule =
|
|
1059
|
+
LoggerModule = _ts_decorate4([
|
|
985
1060
|
Module({
|
|
986
1061
|
providers: [
|
|
987
1062
|
LoggerService
|
|
@@ -1000,6 +1075,6 @@ function slugify(name) {
|
|
|
1000
1075
|
}
|
|
1001
1076
|
__name(slugify, "slugify");
|
|
1002
1077
|
|
|
1003
|
-
export { AllianceException, AllianceExceptionFilter, AllianceGqlException, AllianceHeaders, DatabasesErrorCodes, GatewayErrorCodes, LoggerModule, LoggerService, PortalErrorCodes, SharedConfigKeys, authMiddleware, createBearerToken, createPublicDistributionFiles, createSystemUserToken, getAppManifests, getPrivateKey, slugify };
|
|
1078
|
+
export { AllianceException, AllianceExceptionFilter, AllianceGqlException, AllianceHeaders, DatabasesErrorCodes, GatewayErrorCodes, LoggerModule, LoggerService, PortalErrorCodes, RedisHealthIndicator, SharedConfigKeys, authMiddleware, createBearerToken, createPublicDistributionFiles, createSystemUserToken, getAppManifests, getPrivateKey, slugify, zBooleanEnum, zNonEmptyString, zSharedConfig };
|
|
1004
1079
|
//# sourceMappingURL=out.js.map
|
|
1005
1080
|
//# sourceMappingURL=index.js.map
|