@yobytechautomation/config-lib 0.1.3 → 0.1.5

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.
@@ -57,4 +57,21 @@ export interface BaseConfigService {
57
57
  };
58
58
  };
59
59
  }
60
+ /**
61
+ * 🔥 BASE IMPLEMENTATION (LICENSE CONTROL)
62
+ */
63
+ export declare abstract class BaseConfigServiceImpl implements BaseConfigService {
64
+ protected env: Record<string, any>;
65
+ constructor();
66
+ private validateLicense;
67
+ abstract getDatabaseConfig(): TypeOrmModuleOptions;
68
+ abstract getPort(): number;
69
+ abstract getMode(): string;
70
+ abstract getConsulConfig(): any;
71
+ abstract getRedisConfig(): any;
72
+ abstract getJWTConfig(): any;
73
+ abstract getJUtilConfig(): any;
74
+ abstract getMailConfig(): any;
75
+ abstract getKAFKAConfig(): any;
76
+ }
60
77
  export declare const BASE_CONFIG_SERVICE: unique symbol;
@@ -1,4 +1,76 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BASE_CONFIG_SERVICE = void 0;
39
+ exports.BASE_CONFIG_SERVICE = exports.BaseConfigServiceImpl = void 0;
40
+ const axios_1 = __importDefault(require("axios"));
41
+ const dotenv = __importStar(require("dotenv"));
42
+ // 🔥 LOAD ENV FILE FIRST (VERY IMPORTANT)
43
+ dotenv.config();
44
+ /**
45
+ * 🔥 BASE IMPLEMENTATION (LICENSE CONTROL)
46
+ */
47
+ class BaseConfigServiceImpl {
48
+ constructor() {
49
+ // 🔥 reload env AFTER dotenv
50
+ this.env = process.env;
51
+ this.validateLicense();
52
+ }
53
+ async validateLicense() {
54
+ try {
55
+ const apiKey = this.env.LICENSE_KEY;
56
+ if (!apiKey) {
57
+ throw new Error('LICENSE_KEY missing');
58
+ }
59
+ const res = await axios_1.default.get('http://localhost:3000/license/check', {
60
+ headers: {
61
+ 'x-api-key': apiKey,
62
+ },
63
+ });
64
+ if (res.data.status !== 'active') {
65
+ throw new Error('License invalid');
66
+ }
67
+ console.log('✅ License validated');
68
+ }
69
+ catch (err) {
70
+ console.error('❌ LICENSE ERROR:', err.message);
71
+ process.exit(1);
72
+ }
73
+ }
74
+ }
75
+ exports.BaseConfigServiceImpl = BaseConfigServiceImpl;
4
76
  exports.BASE_CONFIG_SERVICE = Symbol('BASE_CONFIG_SERVICE');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yobytechautomation/config-lib",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Shared multi-environment configuration helpers for SDC NestJS services",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,5 +27,8 @@
27
27
  "@types/node": "^24.10.1",
28
28
  "rimraf": "^6.0.0",
29
29
  "typescript": "^5.0.0"
30
+ },
31
+ "dependencies": {
32
+ "axios": "^1.13.6"
30
33
  }
31
34
  }