bozonx-social-media-posting 1.1.0
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 +1003 -0
- package/dist/src/app.constants.d.ts +8 -0
- package/dist/src/app.constants.js +9 -0
- package/dist/src/app.constants.js.map +1 -0
- package/dist/src/common/enums/body-format.enum.d.ts +12 -0
- package/dist/src/common/enums/body-format.enum.js +14 -0
- package/dist/src/common/enums/body-format.enum.js.map +1 -0
- package/dist/src/common/enums/error-code.enum.d.ts +12 -0
- package/dist/src/common/enums/error-code.enum.js +14 -0
- package/dist/src/common/enums/error-code.enum.js.map +1 -0
- package/dist/src/common/enums/index.d.ts +3 -0
- package/dist/src/common/enums/index.js +4 -0
- package/dist/src/common/enums/index.js.map +1 -0
- package/dist/src/common/enums/post-type.enum.d.ts +28 -0
- package/dist/src/common/enums/post-type.enum.js +30 -0
- package/dist/src/common/enums/post-type.enum.js.map +1 -0
- package/dist/src/common/filters/all-exceptions.filter.d.ts +13 -0
- package/dist/src/common/filters/all-exceptions.filter.js +103 -0
- package/dist/src/common/filters/all-exceptions.filter.js.map +1 -0
- package/dist/src/common/helpers/media-input.helper.d.ts +73 -0
- package/dist/src/common/helpers/media-input.helper.js +122 -0
- package/dist/src/common/helpers/media-input.helper.js.map +1 -0
- package/dist/src/common/interceptors/shutdown.interceptor.d.ts +12 -0
- package/dist/src/common/interceptors/shutdown.interceptor.js +41 -0
- package/dist/src/common/interceptors/shutdown.interceptor.js.map +1 -0
- package/dist/src/common/interfaces/logger.interface.d.ts +44 -0
- package/dist/src/common/interfaces/logger.interface.js +44 -0
- package/dist/src/common/interfaces/logger.interface.js.map +1 -0
- package/dist/src/common/services/shutdown.module.d.ts +2 -0
- package/dist/src/common/services/shutdown.module.js +18 -0
- package/dist/src/common/services/shutdown.module.js.map +1 -0
- package/dist/src/common/services/shutdown.service.d.ts +40 -0
- package/dist/src/common/services/shutdown.service.js +122 -0
- package/dist/src/common/services/shutdown.service.js.map +1 -0
- package/dist/src/common/types/index.d.ts +1 -0
- package/dist/src/common/types/index.js +2 -0
- package/dist/src/common/types/index.js.map +1 -0
- package/dist/src/common/types/media-input.type.d.ts +29 -0
- package/dist/src/common/types/media-input.type.js +2 -0
- package/dist/src/common/types/media-input.type.js.map +1 -0
- package/dist/src/common/validators/body-length.validator.d.ts +24 -0
- package/dist/src/common/validators/body-length.validator.js +57 -0
- package/dist/src/common/validators/body-length.validator.js.map +1 -0
- package/dist/src/common/validators/channel-id.validator.d.ts +19 -0
- package/dist/src/common/validators/channel-id.validator.js +58 -0
- package/dist/src/common/validators/channel-id.validator.js.map +1 -0
- package/dist/src/common/validators/has-content.validator.d.ts +23 -0
- package/dist/src/common/validators/has-content.validator.js +57 -0
- package/dist/src/common/validators/has-content.validator.js.map +1 -0
- package/dist/src/common/validators/media-input.validator.d.ts +44 -0
- package/dist/src/common/validators/media-input.validator.js +112 -0
- package/dist/src/common/validators/media-input.validator.js.map +1 -0
- package/dist/src/common/validators/media-priority.validator.d.ts +19 -0
- package/dist/src/common/validators/media-priority.validator.js +38 -0
- package/dist/src/common/validators/media-priority.validator.js.map +1 -0
- package/dist/src/config/app.config.d.ts +33 -0
- package/dist/src/config/app.config.js +83 -0
- package/dist/src/config/app.config.js.map +1 -0
- package/dist/src/config/library.config.d.ts +51 -0
- package/dist/src/config/library.config.js +197 -0
- package/dist/src/config/library.config.js.map +1 -0
- package/dist/src/config/yaml-config.dto.d.ts +37 -0
- package/dist/src/config/yaml-config.dto.js +152 -0
- package/dist/src/config/yaml-config.dto.js.map +1 -0
- package/dist/src/config/yaml.config.d.ts +14 -0
- package/dist/src/config/yaml.config.js +72 -0
- package/dist/src/config/yaml.config.js.map +1 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/index.js +17 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/library.d.ts +57 -0
- package/dist/src/library.js +92 -0
- package/dist/src/library.js.map +1 -0
- package/dist/src/modules/app-config/app-config.module.d.ts +2 -0
- package/dist/src/modules/app-config/app-config.module.js +26 -0
- package/dist/src/modules/app-config/app-config.module.js.map +1 -0
- package/dist/src/modules/app-config/app-config.service.d.ts +14 -0
- package/dist/src/modules/app-config/app-config.service.js +18 -0
- package/dist/src/modules/app-config/app-config.service.js.map +1 -0
- package/dist/src/modules/app-config/interfaces/app-config.interface.d.ts +31 -0
- package/dist/src/modules/app-config/interfaces/app-config.interface.js +2 -0
- package/dist/src/modules/app-config/interfaces/app-config.interface.js.map +1 -0
- package/dist/src/modules/app-config/nest-config.service.d.ts +41 -0
- package/dist/src/modules/app-config/nest-config.service.js +91 -0
- package/dist/src/modules/app-config/nest-config.service.js.map +1 -0
- package/dist/src/modules/health/health.controller.d.ts +12 -0
- package/dist/src/modules/health/health.controller.js +33 -0
- package/dist/src/modules/health/health.controller.js.map +1 -0
- package/dist/src/modules/health/health.module.d.ts +2 -0
- package/dist/src/modules/health/health.module.js +17 -0
- package/dist/src/modules/health/health.module.js.map +1 -0
- package/dist/src/modules/media/media.module.d.ts +2 -0
- package/dist/src/modules/media/media.module.js +18 -0
- package/dist/src/modules/media/media.module.js.map +1 -0
- package/dist/src/modules/media/media.service.d.ts +15 -0
- package/dist/src/modules/media/media.service.js +49 -0
- package/dist/src/modules/media/media.service.js.map +1 -0
- package/dist/src/modules/platforms/base/auth-validator-registry.service.d.ts +25 -0
- package/dist/src/modules/platforms/base/auth-validator-registry.service.js +50 -0
- package/dist/src/modules/platforms/base/auth-validator-registry.service.js.map +1 -0
- package/dist/src/modules/platforms/base/auth-validator.interface.d.ts +16 -0
- package/dist/src/modules/platforms/base/auth-validator.interface.js +2 -0
- package/dist/src/modules/platforms/base/auth-validator.interface.js.map +1 -0
- package/dist/src/modules/platforms/base/index.d.ts +4 -0
- package/dist/src/modules/platforms/base/index.js +5 -0
- package/dist/src/modules/platforms/base/index.js.map +1 -0
- package/dist/src/modules/platforms/base/platform-registry.service.d.ts +31 -0
- package/dist/src/modules/platforms/base/platform-registry.service.js +54 -0
- package/dist/src/modules/platforms/base/platform-registry.service.js.map +1 -0
- package/dist/src/modules/platforms/base/platform.interface.d.ts +39 -0
- package/dist/src/modules/platforms/base/platform.interface.js +2 -0
- package/dist/src/modules/platforms/base/platform.interface.js.map +1 -0
- package/dist/src/modules/platforms/platforms.module.d.ts +13 -0
- package/dist/src/modules/platforms/platforms.module.js +59 -0
- package/dist/src/modules/platforms/platforms.module.js.map +1 -0
- package/dist/src/modules/platforms/telegram/telegram-auth.validator.d.ts +19 -0
- package/dist/src/modules/platforms/telegram/telegram-auth.validator.js +51 -0
- package/dist/src/modules/platforms/telegram/telegram-auth.validator.js.map +1 -0
- package/dist/src/modules/platforms/telegram/telegram-type-detector.service.d.ts +18 -0
- package/dist/src/modules/platforms/telegram/telegram-type-detector.service.js +47 -0
- package/dist/src/modules/platforms/telegram/telegram-type-detector.service.js.map +1 -0
- package/dist/src/modules/platforms/telegram/telegram.platform.d.ts +58 -0
- package/dist/src/modules/platforms/telegram/telegram.platform.js +434 -0
- package/dist/src/modules/platforms/telegram/telegram.platform.js.map +1 -0
- package/dist/src/modules/post/base-post.service.d.ts +64 -0
- package/dist/src/modules/post/base-post.service.js +99 -0
- package/dist/src/modules/post/base-post.service.js.map +1 -0
- package/dist/src/modules/post/dto/index.d.ts +3 -0
- package/dist/src/modules/post/dto/index.js +4 -0
- package/dist/src/modules/post/dto/index.js.map +1 -0
- package/dist/src/modules/post/dto/post-request.dto.d.ts +56 -0
- package/dist/src/modules/post/dto/post-request.dto.js +195 -0
- package/dist/src/modules/post/dto/post-request.dto.js.map +1 -0
- package/dist/src/modules/post/dto/post-response.dto.d.ts +41 -0
- package/dist/src/modules/post/dto/post-response.dto.js +2 -0
- package/dist/src/modules/post/dto/post-response.dto.js.map +1 -0
- package/dist/src/modules/post/dto/preview-response.dto.d.ts +33 -0
- package/dist/src/modules/post/dto/preview-response.dto.js +2 -0
- package/dist/src/modules/post/dto/preview-response.dto.js.map +1 -0
- package/dist/src/modules/post/idempotency.service.d.ts +95 -0
- package/dist/src/modules/post/idempotency.service.js +229 -0
- package/dist/src/modules/post/idempotency.service.js.map +1 -0
- package/dist/src/modules/post/post.controller.d.ts +13 -0
- package/dist/src/modules/post/post.controller.js +97 -0
- package/dist/src/modules/post/post.controller.js.map +1 -0
- package/dist/src/modules/post/post.module.d.ts +2 -0
- package/dist/src/modules/post/post.module.js +25 -0
- package/dist/src/modules/post/post.module.js.map +1 -0
- package/dist/src/modules/post/post.service.d.ts +62 -0
- package/dist/src/modules/post/post.service.js +325 -0
- package/dist/src/modules/post/post.service.js.map +1 -0
- package/dist/src/modules/post/preview.service.d.ts +23 -0
- package/dist/src/modules/post/preview.service.js +69 -0
- package/dist/src/modules/post/preview.service.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { registerAs } from '@nestjs/config';
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import * as yaml from 'js-yaml';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { validateYamlConfig } from './yaml-config.dto.js';
|
|
6
|
+
/**
|
|
7
|
+
* Namespace for YAML configuration in NestJS ConfigService
|
|
8
|
+
*/
|
|
9
|
+
export const YAML_CONFIG_NAMESPACE = 'yaml_config';
|
|
10
|
+
/**
|
|
11
|
+
* Recursively substitutes environment variables in configuration values
|
|
12
|
+
* Supports ${VAR_NAME} syntax for variable interpolation
|
|
13
|
+
* @param obj - Configuration object, array, or primitive value
|
|
14
|
+
* @returns Processed value with environment variables substituted
|
|
15
|
+
* @throws Error if a referenced environment variable is not defined
|
|
16
|
+
*/
|
|
17
|
+
const substituteEnvVariables = (obj) => {
|
|
18
|
+
if (typeof obj === 'string') {
|
|
19
|
+
return obj.replace(/\$\{([^}]+)\}/g, (_, varName) => {
|
|
20
|
+
const value = process.env[varName];
|
|
21
|
+
if (value === undefined) {
|
|
22
|
+
throw new Error(`Environment variable ${varName} is not defined`);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(obj)) {
|
|
28
|
+
return obj.map(item => substituteEnvVariables(item));
|
|
29
|
+
}
|
|
30
|
+
if (obj !== null && typeof obj === 'object') {
|
|
31
|
+
const result = {};
|
|
32
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
33
|
+
result[key] = substituteEnvVariables(value);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
return obj;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Loads and parses YAML configuration file
|
|
41
|
+
* Reads the file from CONFIG_PATH environment variable or default location
|
|
42
|
+
* Automatically substitutes environment variables in the configuration
|
|
43
|
+
* Validates the configuration structure and values
|
|
44
|
+
* @returns Parsed and validated configuration object with environment variables resolved
|
|
45
|
+
* @throws Error if the configuration file cannot be loaded, parsed, or validated
|
|
46
|
+
*/
|
|
47
|
+
export default registerAs(YAML_CONFIG_NAMESPACE, () => {
|
|
48
|
+
const configPath = process.env.CONFIG_PATH || join(process.cwd(), 'config.yaml');
|
|
49
|
+
try {
|
|
50
|
+
let rawConfig = {};
|
|
51
|
+
try {
|
|
52
|
+
const fileContent = readFileSync(configPath, 'utf8');
|
|
53
|
+
rawConfig = yaml.load(fileContent) || {};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error.code !== 'ENOENT') {
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
// If file doesn't exist, we use empty config to rely on defaults
|
|
60
|
+
rawConfig = {};
|
|
61
|
+
}
|
|
62
|
+
const configWithEnv = substituteEnvVariables(rawConfig);
|
|
63
|
+
// Validate configuration structure and values
|
|
64
|
+
// plainToClass will apply default values from YamlConfigDto instance
|
|
65
|
+
const validatedConfig = validateYamlConfig(configWithEnv);
|
|
66
|
+
return validatedConfig;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
throw new Error(`Failed to load config from ${configPath}: ${error.message}`);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=yaml.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml.config.js","sourceRoot":"","sources":["../../../src/config/yaml.config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,sBAAsB,GAAG,CAAC,GAAQ,EAAO,EAAE;IAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,GAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE;YAChD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACnC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,iBAAiB,CAAC,CAAC;YACtE,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1C,MAA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 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API for library mode
|
|
3
|
+
* Main entry point for using social-media-posting-microservice as a library
|
|
4
|
+
*/
|
|
5
|
+
export { PostService } from './modules/post/post.service.js';
|
|
6
|
+
export { PreviewService } from './modules/post/preview.service.js';
|
|
7
|
+
export { PostRequestDto } from './modules/post/dto/post-request.dto.js';
|
|
8
|
+
export type { PostResponseDto, ErrorResponseDto } from './modules/post/dto/post-response.dto.js';
|
|
9
|
+
export type { PreviewResponseDto, PreviewErrorResponseDto } from './modules/post/dto/preview-response.dto.js';
|
|
10
|
+
export { PostType } from './common/enums/post-type.enum.js';
|
|
11
|
+
export { BodyFormat } from './common/enums/body-format.enum.js';
|
|
12
|
+
export { ErrorCode } from './common/enums/error-code.enum.js';
|
|
13
|
+
export type { MediaInput, MediaInputObject, MediaType } from './common/types/media-input.type.js';
|
|
14
|
+
export type { AppConfig } from './config/app.config.js';
|
|
15
|
+
export type { AccountConfig } from './modules/app-config/interfaces/app-config.interface.js';
|
|
16
|
+
export { createPostingClient } from './library.js';
|
|
17
|
+
export type { LibraryConfig, PostingClient } from './library.js';
|
|
18
|
+
export type { ILogger } from './common/interfaces/logger.interface.js';
|
|
19
|
+
export { ConsoleLogger } from './common/interfaces/logger.interface.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API for library mode
|
|
3
|
+
* Main entry point for using social-media-posting-microservice as a library
|
|
4
|
+
*/
|
|
5
|
+
// Services
|
|
6
|
+
export { PostService } from './modules/post/post.service.js';
|
|
7
|
+
export { PreviewService } from './modules/post/preview.service.js';
|
|
8
|
+
// DTOs
|
|
9
|
+
export { PostRequestDto } from './modules/post/dto/post-request.dto.js';
|
|
10
|
+
// Enums
|
|
11
|
+
export { PostType } from './common/enums/post-type.enum.js';
|
|
12
|
+
export { BodyFormat } from './common/enums/body-format.enum.js';
|
|
13
|
+
export { ErrorCode } from './common/enums/error-code.enum.js';
|
|
14
|
+
// Library mode factory
|
|
15
|
+
export { createPostingClient } from './library.js';
|
|
16
|
+
export { ConsoleLogger } from './common/interfaces/logger.interface.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,WAAW;AACX,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO;AACP,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAIxE,QAAQ;AACR,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAS9D,uBAAuB;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAKnD,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library mode factory
|
|
3
|
+
* Provides standalone initialization without NestJS HTTP server
|
|
4
|
+
*/
|
|
5
|
+
import type { PostRequestDto, PostResponseDto, ErrorResponseDto } from './modules/post/dto/index.js';
|
|
6
|
+
import type { PreviewResponseDto, PreviewErrorResponseDto } from './modules/post/dto/index.js';
|
|
7
|
+
import type { AccountConfig } from './modules/app-config/interfaces/app-config.interface.js';
|
|
8
|
+
import { ILogger } from './common/interfaces/logger.interface.js';
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for library mode
|
|
11
|
+
*/
|
|
12
|
+
export interface LibraryConfig {
|
|
13
|
+
/** Named account configurations */
|
|
14
|
+
accounts: Record<string, AccountConfig>;
|
|
15
|
+
/** Request timeout in seconds (default: 60) */
|
|
16
|
+
requestTimeoutSecs?: number;
|
|
17
|
+
/** Number of retry attempts on error (default: 3) */
|
|
18
|
+
retryAttempts?: number;
|
|
19
|
+
/** Delay between retry attempts in milliseconds (default: 1000) */
|
|
20
|
+
retryDelayMs?: number;
|
|
21
|
+
/** Time-to-live for idempotency records in minutes (default: 10) */
|
|
22
|
+
idempotencyTtlMinutes?: number;
|
|
23
|
+
/** Log level (default: 'warn') */
|
|
24
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
25
|
+
/** Custom logger implementation (default: ConsoleLogger) */
|
|
26
|
+
logger?: ILogger;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Posting client interface
|
|
30
|
+
* Main API for library usage
|
|
31
|
+
*/
|
|
32
|
+
export interface PostingClient {
|
|
33
|
+
/**
|
|
34
|
+
* Publish a post to a social media platform
|
|
35
|
+
* @param request - Post request with platform, content, and media
|
|
36
|
+
* @param abortSignal - Optional signal to abort the operation
|
|
37
|
+
* @returns Success response with post details or error response
|
|
38
|
+
*/
|
|
39
|
+
post(request: PostRequestDto, abortSignal?: AbortSignal): Promise<PostResponseDto | ErrorResponseDto>;
|
|
40
|
+
/**
|
|
41
|
+
* Preview a post without actually publishing it
|
|
42
|
+
* @param request - Post request to preview
|
|
43
|
+
* @returns Preview response with validation results or error response
|
|
44
|
+
*/
|
|
45
|
+
preview(request: PostRequestDto): Promise<PreviewResponseDto | PreviewErrorResponseDto>;
|
|
46
|
+
/**
|
|
47
|
+
* Cleanup resources and shutdown gracefully
|
|
48
|
+
*/
|
|
49
|
+
destroy(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a posting client for library usage
|
|
53
|
+
* Initializes all necessary services without NestJS HTTP server
|
|
54
|
+
* @param config - Library configuration
|
|
55
|
+
* @returns PostingClient instance ready to use
|
|
56
|
+
*/
|
|
57
|
+
export declare function createPostingClient(config: LibraryConfig): PostingClient;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library mode factory
|
|
3
|
+
* Provides standalone initialization without NestJS HTTP server
|
|
4
|
+
*/
|
|
5
|
+
import { Logger as NestLogger } from '@nestjs/common';
|
|
6
|
+
import { PostService } from './modules/post/post.service.js';
|
|
7
|
+
import { PreviewService } from './modules/post/preview.service.js';
|
|
8
|
+
import { PlatformRegistry } from './modules/platforms/base/platform-registry.service.js';
|
|
9
|
+
import { AuthValidatorRegistry } from './modules/platforms/base/auth-validator-registry.service.js';
|
|
10
|
+
import { IdempotencyService } from './modules/post/idempotency.service.js';
|
|
11
|
+
import { ShutdownService } from './common/services/shutdown.service.js';
|
|
12
|
+
import { LibraryConfigService } from './config/library.config.js';
|
|
13
|
+
import { ConsoleLogger } from './common/interfaces/logger.interface.js';
|
|
14
|
+
// function mapLogLevel ...
|
|
15
|
+
function mapLogLevel(level) {
|
|
16
|
+
// 'debug' | 'info' | 'warn' | 'error'
|
|
17
|
+
switch (level) {
|
|
18
|
+
case 'debug':
|
|
19
|
+
return ['error', 'warn', 'log', 'debug'];
|
|
20
|
+
case 'info':
|
|
21
|
+
return ['error', 'warn', 'log'];
|
|
22
|
+
case 'warn':
|
|
23
|
+
return ['error', 'warn'];
|
|
24
|
+
case 'error':
|
|
25
|
+
return ['error'];
|
|
26
|
+
default:
|
|
27
|
+
return ['error', 'warn'];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a posting client for library usage
|
|
32
|
+
* Initializes all necessary services without NestJS HTTP server
|
|
33
|
+
* @param config - Library configuration
|
|
34
|
+
* @returns PostingClient instance ready to use
|
|
35
|
+
*/
|
|
36
|
+
export function createPostingClient(config) {
|
|
37
|
+
// Validate configuration happens in LibraryConfigService constructor
|
|
38
|
+
// Use custom logger if provided, otherwise create ConsoleLogger
|
|
39
|
+
const logLevel = config.logLevel ?? 'warn';
|
|
40
|
+
const logger = config.logger ?? new ConsoleLogger(logLevel);
|
|
41
|
+
// Override NestJS logger to use our custom logger
|
|
42
|
+
// This ensures all NestJS services use the provided logger
|
|
43
|
+
NestLogger.overrideLogger({
|
|
44
|
+
log: (message, context) => logger.log(message, context),
|
|
45
|
+
error: (message, trace, context) => logger.error(message, trace, context),
|
|
46
|
+
warn: (message, context) => logger.warn(message, context),
|
|
47
|
+
debug: (message, context) => logger.debug(message, context),
|
|
48
|
+
verbose: (message, context) => logger.log(message, context),
|
|
49
|
+
});
|
|
50
|
+
// Create app config service
|
|
51
|
+
const appConfigService = new LibraryConfigService(config);
|
|
52
|
+
// Create platform registry and auth validator registry (no constructor args)
|
|
53
|
+
const platformRegistry = new PlatformRegistry();
|
|
54
|
+
const authValidatorRegistry = new AuthValidatorRegistry();
|
|
55
|
+
// Create shutdown service
|
|
56
|
+
const shutdownService = new ShutdownService();
|
|
57
|
+
// Create in-memory cache manager for idempotency
|
|
58
|
+
const cacheManager = {
|
|
59
|
+
async get(key) {
|
|
60
|
+
return undefined; // Fallback to in-memory implementation in IdempotencyService
|
|
61
|
+
},
|
|
62
|
+
async set(key, value, ttl) {
|
|
63
|
+
// No-op - IdempotencyService uses in-memory storage
|
|
64
|
+
},
|
|
65
|
+
async del(key) {
|
|
66
|
+
// No-op
|
|
67
|
+
},
|
|
68
|
+
async reset() {
|
|
69
|
+
// No-op
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
// Create idempotency service with mock cache manager
|
|
73
|
+
const idempotencyService = new IdempotencyService(cacheManager, appConfigService);
|
|
74
|
+
// Create main services
|
|
75
|
+
const postService = new PostService(appConfigService, platformRegistry, authValidatorRegistry, idempotencyService, shutdownService);
|
|
76
|
+
const previewService = new PreviewService(appConfigService, platformRegistry, authValidatorRegistry);
|
|
77
|
+
// Return client interface
|
|
78
|
+
return {
|
|
79
|
+
async post(request, abortSignal) {
|
|
80
|
+
return postService.publish(request, abortSignal);
|
|
81
|
+
},
|
|
82
|
+
async preview(request) {
|
|
83
|
+
return previewService.preview(request);
|
|
84
|
+
},
|
|
85
|
+
async destroy() {
|
|
86
|
+
// ShutdownService doesn't have a shutdown method, trigger lifecycle event manually
|
|
87
|
+
await shutdownService.onApplicationShutdown('manual');
|
|
88
|
+
shutdownService.onModuleDestroy();
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=library.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library.js","sourceRoot":"","sources":["../../src/library.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uDAAuD,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAIlE,OAAO,EAAW,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAsBjF,2BAA2B;AAC3B,SAAS,WAAW,CAAC,KAAa;IAChC,sCAAsC;IACtC,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,OAAO;YACV,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3C,KAAK,MAAM;YACT,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAClC,KAAK,MAAM;YACT,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3B,KAAK,OAAO;YACV,OAAO,CAAC,OAAO,CAAC,CAAC;QACnB;YACE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AA4BD;;;;;GAKG;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,CAAC,CAAC,6DAA6D;QACjF,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,GAAY;YAC7C,oDAAoD;QACtD,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,GAAW;YACnB,QAAQ;QACV,CAAC;QACD,KAAK,CAAC,KAAK;YACT,QAAQ;QACV,CAAC;KACF,CAAC;IAEF,qDAAqD;IACrD,MAAM,kBAAkB,GAAG,IAAK,kBAA0B,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAE3F,uBAAuB;IACvB,MAAM,WAAW,GAAG,IAAI,WAAW,CACjC,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,CAChB,CAAC;IAEF,MAAM,cAAc,GAAG,IAAI,cAAc,CACvC,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,CACtB,CAAC;IAEF,0BAA0B;IAC1B,OAAO;QACL,KAAK,CAAC,IAAI,CAAC,OAAuB,EAAE,WAAyB;YAC3D,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;QAED,KAAK,CAAC,OAAO,CAAC,OAAuB;YACnC,OAAO,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;QAED,KAAK,CAAC,OAAO;YACX,mFAAmF;YACnF,MAAM,eAAe,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;YACtD,eAAe,CAAC,eAAe,EAAE,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from '@nestjs/common';
|
|
8
|
+
import { ConfigModule } from '@nestjs/config';
|
|
9
|
+
import { AppConfigService } from './app-config.service.js';
|
|
10
|
+
import { NestConfigService } from './nest-config.service.js';
|
|
11
|
+
let AppConfigModule = class AppConfigModule {
|
|
12
|
+
};
|
|
13
|
+
AppConfigModule = __decorate([
|
|
14
|
+
Module({
|
|
15
|
+
imports: [ConfigModule],
|
|
16
|
+
providers: [
|
|
17
|
+
{
|
|
18
|
+
provide: AppConfigService,
|
|
19
|
+
useClass: NestConfigService,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
exports: [AppConfigService],
|
|
23
|
+
})
|
|
24
|
+
], AppConfigModule);
|
|
25
|
+
export { AppConfigModule };
|
|
26
|
+
//# sourceMappingURL=app-config.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-config.module.js","sourceRoot":"","sources":["../../../../src/modules/app-config/app-config.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAYtD,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,eAAe;IAV3B,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,YAAY,CAAC;QACvB,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,gBAAgB;gBACzB,QAAQ,EAAE,iBAAiB;aAC5B;SACF;QACD,OAAO,EAAE,CAAC,gBAAgB,CAAC;KAC5B,CAAC;GACW,eAAe,CAAG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AccountConfig } from './interfaces/app-config.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract configuration service
|
|
4
|
+
* Defines the contract for configuration access
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class AppConfigService {
|
|
7
|
+
abstract get<T = any>(path: string): T | undefined;
|
|
8
|
+
abstract getAccount(accountName: string): AccountConfig;
|
|
9
|
+
abstract getAllAccounts(): Record<string, AccountConfig>;
|
|
10
|
+
abstract get requestTimeoutSecs(): number;
|
|
11
|
+
abstract get retryAttempts(): number;
|
|
12
|
+
abstract get retryDelayMs(): number;
|
|
13
|
+
abstract get idempotencyTtlMinutes(): number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Injectable } from '@nestjs/common';
|
|
8
|
+
/**
|
|
9
|
+
* Abstract configuration service
|
|
10
|
+
* Defines the contract for configuration access
|
|
11
|
+
*/
|
|
12
|
+
let AppConfigService = class AppConfigService {
|
|
13
|
+
};
|
|
14
|
+
AppConfigService = __decorate([
|
|
15
|
+
Injectable()
|
|
16
|
+
], AppConfigService);
|
|
17
|
+
export { AppConfigService };
|
|
18
|
+
//# sourceMappingURL=app-config.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-config.service.js","sourceRoot":"","sources":["../../../../src/modules/app-config/app-config.service.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C;;;GAGG;AAEI,IAAe,gBAAgB,GAA/B,MAAe,gBAAgB;CAQrC,CAAA;AARqB,gBAAgB;IADrC,UAAU,EAAE;GACS,gBAAgB,CAQrC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application configuration structure from YAML file
|
|
3
|
+
*/
|
|
4
|
+
export interface AppConfig {
|
|
5
|
+
/** Request timeout (seconds) */
|
|
6
|
+
requestTimeoutSecs: number;
|
|
7
|
+
/** Number of retry attempts on error */
|
|
8
|
+
retryAttempts: number;
|
|
9
|
+
/** Delay between retry attempts (milliseconds) */
|
|
10
|
+
retryDelayMs: number;
|
|
11
|
+
/** Time-to-live for idempotency records in cache (minutes) */
|
|
12
|
+
idempotencyTtlMinutes: number;
|
|
13
|
+
/** Named account configurations */
|
|
14
|
+
accounts?: Record<string, AccountConfig>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Account configuration
|
|
18
|
+
* Represents a named account with platform and authentication details
|
|
19
|
+
*/
|
|
20
|
+
export interface AccountConfig {
|
|
21
|
+
/** Platform name (e.g., 'telegram') */
|
|
22
|
+
platform: string;
|
|
23
|
+
/** Authentication credentials */
|
|
24
|
+
auth: Record<string, string>;
|
|
25
|
+
/** Platform-specific channel/chat identifier (e.g., Telegram channel username or chat ID) */
|
|
26
|
+
channelId?: string | number;
|
|
27
|
+
/** Maximum body length for this account (characters) */
|
|
28
|
+
maxBody?: number;
|
|
29
|
+
/** Additional provider-specific settings */
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-config.interface.js","sourceRoot":"","sources":["../../../../../src/modules/app-config/interfaces/app-config.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { AppConfigService } from './app-config.service.js';
|
|
3
|
+
import type { AccountConfig } from './interfaces/app-config.interface.js';
|
|
4
|
+
export declare class NestConfigService extends AppConfigService {
|
|
5
|
+
private readonly configService;
|
|
6
|
+
private readonly config;
|
|
7
|
+
/**
|
|
8
|
+
* Initializes the service and loads YAML configuration
|
|
9
|
+
* @param configService - NestJS ConfigService for accessing configuration
|
|
10
|
+
* @throws Error if YAML configuration section is not loaded
|
|
11
|
+
*/
|
|
12
|
+
constructor(configService: ConfigService);
|
|
13
|
+
/**
|
|
14
|
+
* Get configuration value by dot-notation path
|
|
15
|
+
*/
|
|
16
|
+
get<T = any>(path: string): T | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get a specific account configuration by name
|
|
19
|
+
*/
|
|
20
|
+
getAccount(accountName: string): AccountConfig;
|
|
21
|
+
/**
|
|
22
|
+
* Get all configured accounts
|
|
23
|
+
*/
|
|
24
|
+
getAllAccounts(): Record<string, AccountConfig>;
|
|
25
|
+
/**
|
|
26
|
+
* Get incoming request timeout
|
|
27
|
+
*/
|
|
28
|
+
get requestTimeoutSecs(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Get retry attempts
|
|
31
|
+
*/
|
|
32
|
+
get retryAttempts(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Get retry delay in milliseconds
|
|
35
|
+
*/
|
|
36
|
+
get retryDelayMs(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Get idempotency TTL in minutes
|
|
39
|
+
*/
|
|
40
|
+
get idempotencyTtlMinutes(): number;
|
|
41
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
11
|
+
import { ConfigService } from '@nestjs/config';
|
|
12
|
+
import { YAML_CONFIG_NAMESPACE } from '../../config/yaml.config.js';
|
|
13
|
+
import { AppConfigService } from './app-config.service.js';
|
|
14
|
+
let NestConfigService = class NestConfigService extends AppConfigService {
|
|
15
|
+
configService;
|
|
16
|
+
config;
|
|
17
|
+
/**
|
|
18
|
+
* Initializes the service and loads YAML configuration
|
|
19
|
+
* @param configService - NestJS ConfigService for accessing configuration
|
|
20
|
+
* @throws Error if YAML configuration section is not loaded
|
|
21
|
+
*/
|
|
22
|
+
constructor(configService) {
|
|
23
|
+
super();
|
|
24
|
+
this.configService = configService;
|
|
25
|
+
const loadedConfig = this.configService.get(YAML_CONFIG_NAMESPACE);
|
|
26
|
+
if (!loadedConfig) {
|
|
27
|
+
throw new Error(`Configuration section "${YAML_CONFIG_NAMESPACE}" is not loaded`);
|
|
28
|
+
}
|
|
29
|
+
this.config = loadedConfig;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get configuration value by dot-notation path
|
|
33
|
+
*/
|
|
34
|
+
get(path) {
|
|
35
|
+
const keys = path.split('.');
|
|
36
|
+
let value = this.config;
|
|
37
|
+
for (const key of keys) {
|
|
38
|
+
if (value === undefined || value === null) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
value = value[key];
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get a specific account configuration by name
|
|
47
|
+
*/
|
|
48
|
+
getAccount(accountName) {
|
|
49
|
+
const account = this.config.accounts?.[accountName];
|
|
50
|
+
if (!account) {
|
|
51
|
+
throw new NotFoundException(`Account "${accountName}" not found in configuration`);
|
|
52
|
+
}
|
|
53
|
+
return account;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get all configured accounts
|
|
57
|
+
*/
|
|
58
|
+
getAllAccounts() {
|
|
59
|
+
return this.config.accounts || {};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get incoming request timeout
|
|
63
|
+
*/
|
|
64
|
+
get requestTimeoutSecs() {
|
|
65
|
+
return this.config.requestTimeoutSecs;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get retry attempts
|
|
69
|
+
*/
|
|
70
|
+
get retryAttempts() {
|
|
71
|
+
return this.config.retryAttempts;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get retry delay in milliseconds
|
|
75
|
+
*/
|
|
76
|
+
get retryDelayMs() {
|
|
77
|
+
return this.config.retryDelayMs;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get idempotency TTL in minutes
|
|
81
|
+
*/
|
|
82
|
+
get idempotencyTtlMinutes() {
|
|
83
|
+
return this.config.idempotencyTtlMinutes;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
NestConfigService = __decorate([
|
|
87
|
+
Injectable(),
|
|
88
|
+
__metadata("design:paramtypes", [ConfigService])
|
|
89
|
+
], NestConfigService);
|
|
90
|
+
export { NestConfigService };
|
|
91
|
+
//# sourceMappingURL=nest-config.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-config.service.js","sourceRoot":"","sources":["../../../../src/modules/app-config/nest-config.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC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AO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,IAAI,qBAAqB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC;IAC3C,CAAC;CACF,CAAA;AAjFY,iBAAiB;IAD7B,UAAU,EAAE;qCASiC,aAAa;GAR9C,iBAAiB,CAiF7B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Controller, Get } from '@nestjs/common';
|
|
11
|
+
/**
|
|
12
|
+
* Simple health check controller
|
|
13
|
+
* Provides a minimal `/health` endpoint
|
|
14
|
+
*/
|
|
15
|
+
let HealthController = class HealthController {
|
|
16
|
+
/**
|
|
17
|
+
* Basic health check endpoint returning a simple OK status
|
|
18
|
+
*/
|
|
19
|
+
check() {
|
|
20
|
+
return { status: 'ok' };
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
__decorate([
|
|
24
|
+
Get(),
|
|
25
|
+
__metadata("design:type", Function),
|
|
26
|
+
__metadata("design:paramtypes", []),
|
|
27
|
+
__metadata("design:returntype", void 0)
|
|
28
|
+
], HealthController.prototype, "check", null);
|
|
29
|
+
HealthController = __decorate([
|
|
30
|
+
Controller('health')
|
|
31
|
+
], HealthController);
|
|
32
|
+
export { HealthController };
|
|
33
|
+
//# sourceMappingURL=health.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.controller.js","sourceRoot":"","sources":["../../../../src/modules/health/health.controller.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;GAGG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B;;OAEG;IAEI,KAAK;QACV,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;CACF,CAAA;AAHQ;IADN,GAAG,EAAE;;;;6CAGL;AAPU,gBAAgB;IAD5B,UAAU,CAAC,QAAQ,CAAC;GACR,gBAAgB,CAQ5B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from '@nestjs/common';
|
|
8
|
+
import { HealthController } from './health.controller.js';
|
|
9
|
+
let HealthModule = class HealthModule {
|
|
10
|
+
};
|
|
11
|
+
HealthModule = __decorate([
|
|
12
|
+
Module({
|
|
13
|
+
controllers: [HealthController],
|
|
14
|
+
})
|
|
15
|
+
], HealthModule);
|
|
16
|
+
export { HealthModule };
|
|
17
|
+
//# sourceMappingURL=health.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.module.js","sourceRoot":"","sources":["../../../../src/modules/health/health.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAKnD,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,YAAY;IAHxB,MAAM,CAAC;QACN,WAAW,EAAE,CAAC,gBAAgB,CAAC;KAChC,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from '@nestjs/common';
|
|
8
|
+
import { MediaService } from './media.service.js';
|
|
9
|
+
let MediaModule = class MediaModule {
|
|
10
|
+
};
|
|
11
|
+
MediaModule = __decorate([
|
|
12
|
+
Module({
|
|
13
|
+
providers: [MediaService],
|
|
14
|
+
exports: [MediaService],
|
|
15
|
+
})
|
|
16
|
+
], MediaModule);
|
|
17
|
+
export { MediaModule };
|
|
18
|
+
//# sourceMappingURL=media.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.module.js","sourceRoot":"","sources":["../../../../src/modules/media/media.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAM3C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IAJvB,MAAM,CAAC;QACN,SAAS,EAAE,CAAC,YAAY,CAAC;QACzB,OAAO,EAAE,CAAC,YAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"}
|