@bmfk/api 0.0.0-stage → 1.0.1
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 +90 -0
- package/LICENSE +21 -0
- package/README.md +1293 -2
- package/dist/apiServer/APIService.d.ts +125 -0
- package/dist/apiServer/APIService.js +769 -0
- package/dist/apiServer/BaseEndpoint.d.ts +90 -0
- package/dist/apiServer/BaseEndpoint.js +314 -0
- package/dist/apiServer/BaseService.d.ts +17 -0
- package/dist/apiServer/BaseService.js +39 -0
- package/dist/apiServer/DBService.d.ts +131 -0
- package/dist/apiServer/DBService.js +290 -0
- package/dist/apiServer/DocumentService.d.ts +9 -0
- package/dist/apiServer/DocumentService.js +65 -0
- package/dist/apiServer/LocalRequest.d.ts +3 -0
- package/dist/apiServer/LocalRequest.js +6 -0
- package/dist/apiServer/LogService.d.ts +78 -0
- package/dist/apiServer/LogService.js +349 -0
- package/dist/apiServer/MonitorService.d.ts +102 -0
- package/dist/apiServer/MonitorService.js +615 -0
- package/dist/apiServer/StatService.d.ts +4 -0
- package/dist/apiServer/StatService.js +10 -0
- package/dist/apiServer/TimeframeService.d.ts +28 -0
- package/dist/apiServer/TimeframeService.js +97 -0
- package/dist/apiServer/WebSocketServer.d.ts +39 -0
- package/dist/apiServer/WebSocketServer.js +173 -0
- package/dist/apiServer/db/IDBAdapter.d.ts +14 -0
- package/dist/apiServer/db/IDBAdapter.js +2 -0
- package/dist/apiServer/db/MysqlAdapter.d.ts +72 -0
- package/dist/apiServer/db/MysqlAdapter.js +869 -0
- package/dist/apiServer/db/PostgresAdapter.d.ts +41 -0
- package/dist/apiServer/db/PostgresAdapter.js +73 -0
- package/dist/apiServer/deployment/AccessConfigWizard.d.ts +5 -0
- package/dist/apiServer/deployment/AccessConfigWizard.js +254 -0
- package/dist/apiServer/deployment/Activate.d.ts +4 -0
- package/dist/apiServer/deployment/Activate.js +124 -0
- package/dist/apiServer/deployment/BackupManager.d.ts +33 -0
- package/dist/apiServer/deployment/BackupManager.js +174 -0
- package/dist/apiServer/deployment/Backups.d.ts +2 -0
- package/dist/apiServer/deployment/Backups.js +44 -0
- package/dist/apiServer/deployment/BlueGreenState.d.ts +31 -0
- package/dist/apiServer/deployment/BlueGreenState.js +150 -0
- package/dist/apiServer/deployment/Bundler.d.ts +12 -0
- package/dist/apiServer/deployment/Bundler.js +178 -0
- package/dist/apiServer/deployment/ConfigService.d.ts +203 -0
- package/dist/apiServer/deployment/ConfigService.js +195 -0
- package/dist/apiServer/deployment/Deploy.d.ts +4 -0
- package/dist/apiServer/deployment/Deploy.js +404 -0
- package/dist/apiServer/deployment/DeployKeyWizard.d.ts +2 -0
- package/dist/apiServer/deployment/DeployKeyWizard.js +84 -0
- package/dist/apiServer/deployment/Deployer.d.ts +13 -0
- package/dist/apiServer/deployment/Deployer.js +96 -0
- package/dist/apiServer/deployment/DeployerInit.d.ts +25 -0
- package/dist/apiServer/deployment/DeployerInit.js +214 -0
- package/dist/apiServer/deployment/DeployerService.d.ts +378 -0
- package/dist/apiServer/deployment/DeployerService.js +1553 -0
- package/dist/apiServer/deployment/HashPassword.d.ts +3 -0
- package/dist/apiServer/deployment/HashPassword.js +126 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.d.ts +1 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.js +202 -0
- package/dist/apiServer/deployment/MigrateProject.d.ts +31 -0
- package/dist/apiServer/deployment/MigrateProject.js +335 -0
- package/dist/apiServer/deployment/NginxHelper.d.ts +10 -0
- package/dist/apiServer/deployment/NginxHelper.js +111 -0
- package/dist/apiServer/deployment/Notifier.d.ts +30 -0
- package/dist/apiServer/deployment/Notifier.js +82 -0
- package/dist/apiServer/deployment/ProjectConfigWizard.d.ts +1 -0
- package/dist/apiServer/deployment/ProjectConfigWizard.js +148 -0
- package/dist/apiServer/deployment/Restore.d.ts +2 -0
- package/dist/apiServer/deployment/Restore.js +89 -0
- package/dist/apiServer/deployment/ReviewStore.d.ts +62 -0
- package/dist/apiServer/deployment/ReviewStore.js +186 -0
- package/dist/apiServer/deployment/SecretsInjector.d.ts +21 -0
- package/dist/apiServer/deployment/SecretsInjector.js +189 -0
- package/dist/apiServer/deployment/SetupConfigWizard.d.ts +1 -0
- package/dist/apiServer/deployment/SetupConfigWizard.js +238 -0
- package/dist/apiServer/deployment/Status.d.ts +2 -0
- package/dist/apiServer/deployment/Status.js +83 -0
- package/dist/apiServer/deployment/TelegramNotifier.d.ts +8 -0
- package/dist/apiServer/deployment/TelegramNotifier.js +23 -0
- package/dist/apiServer/deployment/Watchdog.d.ts +15 -0
- package/dist/apiServer/deployment/Watchdog.js +65 -0
- package/dist/apiServer/deployment/Wizards.d.ts +1 -0
- package/dist/apiServer/deployment/Wizards.js +83 -0
- package/dist/apiServer/deployment/cli.d.ts +2 -0
- package/dist/apiServer/deployment/cli.js +224 -0
- package/dist/apiServer/deployment/cliCommon.d.ts +27 -0
- package/dist/apiServer/deployment/cliCommon.js +110 -0
- package/dist/apiServer/deployment/cliPrompt.d.ts +5 -0
- package/dist/apiServer/deployment/cliPrompt.js +38 -0
- package/dist/apiServer/deployment/resolveConfig.d.ts +19 -0
- package/dist/apiServer/deployment/resolveConfig.js +139 -0
- package/dist/apiServer/documentation/Documentation.d.ts +18 -0
- package/dist/apiServer/documentation/Documentation.js +143 -0
- package/dist/apiServer/documentation/index.html +460 -0
- package/dist/apiServer/external/MicroserviceClient.d.ts +28 -0
- package/dist/apiServer/external/MicroserviceClient.js +144 -0
- package/dist/apiServer/external/MicroserviceHost.d.ts +52 -0
- package/dist/apiServer/external/MicroserviceHost.js +183 -0
- package/dist/apiServer/external/MicroserviceHostController.d.ts +6 -0
- package/dist/apiServer/external/MicroserviceHostController.js +65 -0
- package/dist/apiServer/helper/AppDataPath.d.ts +9 -0
- package/dist/apiServer/helper/AppDataPath.js +81 -0
- package/dist/apiServer/helper/ClientIp.d.ts +3 -0
- package/dist/apiServer/helper/ClientIp.js +33 -0
- package/dist/apiServer/helper/DataProvider.d.ts +18 -0
- package/dist/apiServer/helper/DataProvider.js +57 -0
- package/dist/apiServer/helper/IpAllowList.d.ts +8 -0
- package/dist/apiServer/helper/IpAllowList.js +40 -0
- package/dist/apiServer/helper/JSONStableStringify.d.ts +1 -0
- package/dist/apiServer/helper/JSONStableStringify.js +15 -0
- package/dist/apiServer/helper/PasswordHash.d.ts +5 -0
- package/dist/apiServer/helper/PasswordHash.js +52 -0
- package/dist/apiServer/helper/Sleep.d.ts +1 -0
- package/dist/apiServer/helper/Sleep.js +5 -0
- package/dist/apiServer/helper/Trace.d.ts +8 -0
- package/dist/apiServer/helper/Trace.js +30 -0
- package/dist/apiServer/helper/UID.d.ts +16 -0
- package/dist/apiServer/helper/UID.js +98 -0
- package/dist/apiServer/helper/Validator.d.ts +86 -0
- package/dist/apiServer/helper/Validator.js +560 -0
- package/dist/apiServer/helper/YYYYMMDDHH.d.ts +2 -0
- package/dist/apiServer/helper/YYYYMMDDHH.js +31 -0
- package/dist/apiServer/helper/ZipUtils.d.ts +6 -0
- package/dist/apiServer/helper/ZipUtils.js +28 -0
- package/dist/apiServer/http/Http.d.ts +183 -0
- package/dist/apiServer/http/Http.js +627 -0
- package/dist/apiServer/interceptors/InterceptorPayAuth.d.ts +19 -0
- package/dist/apiServer/interceptors/InterceptorPayAuth.js +124 -0
- package/dist/apiServer/interceptors/InterceptorSignedAuth.d.ts +40 -0
- package/dist/apiServer/interceptors/InterceptorSignedAuth.js +150 -0
- package/dist/apiServer/monitor/AccessStore.d.ts +27 -0
- package/dist/apiServer/monitor/AccessStore.js +163 -0
- package/dist/apiServer/monitor/LogFiles.d.ts +34 -0
- package/dist/apiServer/monitor/LogFiles.js +109 -0
- package/dist/apiServer/monitor/Monitor.d.ts +54 -0
- package/dist/apiServer/monitor/Monitor.js +447 -0
- package/dist/apiServer/monitor/MonitorAuth.d.ts +87 -0
- package/dist/apiServer/monitor/MonitorAuth.js +474 -0
- package/dist/apiServer/monitor/ProcessMonitor.d.ts +177 -0
- package/dist/apiServer/monitor/ProcessMonitor.js +468 -0
- package/dist/apiServer/monitor/SystemInfo.d.ts +70 -0
- package/dist/apiServer/monitor/SystemInfo.js +217 -0
- package/dist/apiServer/monitor/ThreatMonitor.d.ts +73 -0
- package/dist/apiServer/monitor/ThreatMonitor.js +239 -0
- package/dist/apiServer/monitor/index.html +591 -0
- package/dist/apiServer/review/Review.d.ts +23 -0
- package/dist/apiServer/review/Review.js +149 -0
- package/dist/apiServer/review/ReviewAuth.d.ts +56 -0
- package/dist/apiServer/review/ReviewAuth.js +147 -0
- package/dist/apiServer/review/ReviewDiff.d.ts +43 -0
- package/dist/apiServer/review/ReviewDiff.js +175 -0
- package/dist/apiServer/review/index.html +501 -0
- package/dist/apiServer/routes/Liveness.d.ts +7 -0
- package/dist/apiServer/routes/Liveness.js +27 -0
- package/dist/apiServer/routes/Readiness.d.ts +13 -0
- package/dist/apiServer/routes/Readiness.js +20 -0
- package/dist/apiServer/security/BlockedIps.d.ts +46 -0
- package/dist/apiServer/security/BlockedIps.js +185 -0
- package/dist/apiServer/structures/DefaultErrors.d.ts +36 -0
- package/dist/apiServer/structures/DefaultErrors.js +52 -0
- package/dist/apiServer/structures/HTTPStatus.d.ts +7 -0
- package/dist/apiServer/structures/HTTPStatus.js +11 -0
- package/dist/apiServer/structures/Interfaces.d.ts +55 -0
- package/dist/apiServer/structures/Interfaces.js +2 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +110 -0
- package/dist/signal/Signal.d.ts +23 -0
- package/dist/signal/Signal.js +85 -0
- package/package.json +88 -4
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Signal, Req } from "../../signal/Signal";
|
|
2
|
+
import { BaseService } from "../BaseService";
|
|
3
|
+
import { ValidationModel } from "../helper/Validator";
|
|
4
|
+
declare const _ProjectState: {
|
|
5
|
+
readonly active: "";
|
|
6
|
+
readonly $__active_values: readonly ["blue", "green"];
|
|
7
|
+
readonly lastDeployed: "";
|
|
8
|
+
readonly $__lastDeployed_values: readonly ["blue", "green"];
|
|
9
|
+
readonly history: readonly [{
|
|
10
|
+
readonly slot: "";
|
|
11
|
+
readonly $__slot_values: readonly ["blue", "green"];
|
|
12
|
+
readonly action: "";
|
|
13
|
+
readonly $__action_values: readonly ["deploy", "switch", "rollback", "restore"];
|
|
14
|
+
readonly user: "";
|
|
15
|
+
readonly at: 0;
|
|
16
|
+
}];
|
|
17
|
+
readonly statusToken: "";
|
|
18
|
+
readonly $__statusToken_optional: true;
|
|
19
|
+
};
|
|
20
|
+
export type IProjectState = ValidationModel<typeof _ProjectState>;
|
|
21
|
+
declare const _TConfig: {
|
|
22
|
+
readonly name: "";
|
|
23
|
+
readonly destination: "";
|
|
24
|
+
readonly description: "";
|
|
25
|
+
readonly token: "";
|
|
26
|
+
readonly unpack: true;
|
|
27
|
+
readonly ignoreDirectoryClean: false;
|
|
28
|
+
readonly backup: true;
|
|
29
|
+
readonly install: true;
|
|
30
|
+
readonly omitDev: false;
|
|
31
|
+
readonly $__omitDev_optional: true;
|
|
32
|
+
readonly migrate: false;
|
|
33
|
+
readonly $__migrate_optional: true;
|
|
34
|
+
readonly pm2: true;
|
|
35
|
+
readonly pm2_attributes: readonly [""];
|
|
36
|
+
readonly $__pm2_attributes_optional: true;
|
|
37
|
+
readonly chmod: 0;
|
|
38
|
+
readonly $__chmod_optional: true;
|
|
39
|
+
readonly email: readonly [""];
|
|
40
|
+
readonly $__email_optional: true;
|
|
41
|
+
readonly phone: readonly [""];
|
|
42
|
+
readonly $__phone_optional: true;
|
|
43
|
+
readonly liveness: "";
|
|
44
|
+
readonly $__liveness_optional: true;
|
|
45
|
+
readonly readiness: "";
|
|
46
|
+
readonly $__readiness_optional: true;
|
|
47
|
+
readonly config: {};
|
|
48
|
+
readonly bluegreen: {
|
|
49
|
+
readonly blue_config: {};
|
|
50
|
+
readonly blue_pm2_attributes: readonly [""];
|
|
51
|
+
readonly $__blue_pm2_attributes_optional: true;
|
|
52
|
+
readonly green_config: {};
|
|
53
|
+
readonly green_pm2_attributes: readonly [""];
|
|
54
|
+
readonly $__green_pm2_attributes_optional: true;
|
|
55
|
+
readonly on_switch: readonly [""];
|
|
56
|
+
readonly $__on_switch_optional: true;
|
|
57
|
+
};
|
|
58
|
+
readonly $__bluegreen_optional: true;
|
|
59
|
+
readonly nginx: {
|
|
60
|
+
readonly config_dir: "";
|
|
61
|
+
readonly $__config_dir_optional: true;
|
|
62
|
+
readonly domain: "";
|
|
63
|
+
readonly $__domain_optional: true;
|
|
64
|
+
readonly upstream_name: "";
|
|
65
|
+
readonly $__upstream_name_optional: true;
|
|
66
|
+
};
|
|
67
|
+
readonly $__nginx_optional: true;
|
|
68
|
+
readonly review: {
|
|
69
|
+
readonly reviewers: readonly [""];
|
|
70
|
+
readonly mode: "";
|
|
71
|
+
readonly $__mode_values: readonly ["any", "all"];
|
|
72
|
+
readonly ttlHours: 24;
|
|
73
|
+
readonly $__ttlHours_optional: true;
|
|
74
|
+
};
|
|
75
|
+
readonly $__review_optional: true;
|
|
76
|
+
readonly secrets: {
|
|
77
|
+
readonly dir: "";
|
|
78
|
+
readonly $__dir_optional: true;
|
|
79
|
+
readonly file: "";
|
|
80
|
+
readonly $__file_optional: true;
|
|
81
|
+
};
|
|
82
|
+
readonly $__secrets_optional: true;
|
|
83
|
+
};
|
|
84
|
+
export type IConfig = ValidationModel<typeof _TConfig>;
|
|
85
|
+
export declare function projectNameProblem(name: unknown): string | null;
|
|
86
|
+
export declare const PROJECT_CONFIG_MODEL: {
|
|
87
|
+
readonly name: "";
|
|
88
|
+
readonly destination: "";
|
|
89
|
+
readonly description: "";
|
|
90
|
+
readonly token: "";
|
|
91
|
+
readonly unpack: true;
|
|
92
|
+
readonly ignoreDirectoryClean: false;
|
|
93
|
+
readonly backup: true;
|
|
94
|
+
readonly install: true;
|
|
95
|
+
readonly omitDev: false;
|
|
96
|
+
readonly $__omitDev_optional: true;
|
|
97
|
+
readonly migrate: false;
|
|
98
|
+
readonly $__migrate_optional: true;
|
|
99
|
+
readonly pm2: true;
|
|
100
|
+
readonly pm2_attributes: readonly [""];
|
|
101
|
+
readonly $__pm2_attributes_optional: true;
|
|
102
|
+
readonly chmod: 0;
|
|
103
|
+
readonly $__chmod_optional: true;
|
|
104
|
+
readonly email: readonly [""];
|
|
105
|
+
readonly $__email_optional: true;
|
|
106
|
+
readonly phone: readonly [""];
|
|
107
|
+
readonly $__phone_optional: true;
|
|
108
|
+
readonly liveness: "";
|
|
109
|
+
readonly $__liveness_optional: true;
|
|
110
|
+
readonly readiness: "";
|
|
111
|
+
readonly $__readiness_optional: true;
|
|
112
|
+
readonly config: {};
|
|
113
|
+
readonly bluegreen: {
|
|
114
|
+
readonly blue_config: {};
|
|
115
|
+
readonly blue_pm2_attributes: readonly [""];
|
|
116
|
+
readonly $__blue_pm2_attributes_optional: true;
|
|
117
|
+
readonly green_config: {};
|
|
118
|
+
readonly green_pm2_attributes: readonly [""];
|
|
119
|
+
readonly $__green_pm2_attributes_optional: true;
|
|
120
|
+
readonly on_switch: readonly [""];
|
|
121
|
+
readonly $__on_switch_optional: true;
|
|
122
|
+
};
|
|
123
|
+
readonly $__bluegreen_optional: true;
|
|
124
|
+
readonly nginx: {
|
|
125
|
+
readonly config_dir: "";
|
|
126
|
+
readonly $__config_dir_optional: true;
|
|
127
|
+
readonly domain: "";
|
|
128
|
+
readonly $__domain_optional: true;
|
|
129
|
+
readonly upstream_name: "";
|
|
130
|
+
readonly $__upstream_name_optional: true;
|
|
131
|
+
};
|
|
132
|
+
readonly $__nginx_optional: true;
|
|
133
|
+
readonly review: {
|
|
134
|
+
readonly reviewers: readonly [""];
|
|
135
|
+
readonly mode: "";
|
|
136
|
+
readonly $__mode_values: readonly ["any", "all"];
|
|
137
|
+
readonly ttlHours: 24;
|
|
138
|
+
readonly $__ttlHours_optional: true;
|
|
139
|
+
};
|
|
140
|
+
readonly $__review_optional: true;
|
|
141
|
+
readonly secrets: {
|
|
142
|
+
readonly dir: "";
|
|
143
|
+
readonly $__dir_optional: true;
|
|
144
|
+
readonly file: "";
|
|
145
|
+
readonly $__file_optional: true;
|
|
146
|
+
};
|
|
147
|
+
readonly $__secrets_optional: true;
|
|
148
|
+
};
|
|
149
|
+
export declare const REQ_DEPLOYMENT_CONFIG: Req<void, Map<string, {
|
|
150
|
+
name: string;
|
|
151
|
+
destination: string;
|
|
152
|
+
description: string;
|
|
153
|
+
token: string;
|
|
154
|
+
unpack: boolean;
|
|
155
|
+
ignoreDirectoryClean: boolean;
|
|
156
|
+
backup: boolean;
|
|
157
|
+
install: boolean;
|
|
158
|
+
omitDev?: boolean | undefined;
|
|
159
|
+
migrate?: boolean | undefined;
|
|
160
|
+
pm2: boolean;
|
|
161
|
+
pm2_attributes?: string[] | undefined;
|
|
162
|
+
chmod?: number | undefined;
|
|
163
|
+
email?: string[] | undefined;
|
|
164
|
+
phone?: string[] | undefined;
|
|
165
|
+
liveness?: string | undefined;
|
|
166
|
+
readiness?: string | undefined;
|
|
167
|
+
config: {};
|
|
168
|
+
bluegreen?: {
|
|
169
|
+
blue_config: {};
|
|
170
|
+
blue_pm2_attributes?: string[] | undefined;
|
|
171
|
+
green_config: {};
|
|
172
|
+
green_pm2_attributes?: string[] | undefined;
|
|
173
|
+
on_switch?: string[] | undefined;
|
|
174
|
+
} | undefined;
|
|
175
|
+
nginx?: {
|
|
176
|
+
config_dir?: string | undefined;
|
|
177
|
+
domain?: string | undefined;
|
|
178
|
+
upstream_name?: string | undefined;
|
|
179
|
+
} | undefined;
|
|
180
|
+
review?: {
|
|
181
|
+
reviewers: string[];
|
|
182
|
+
mode: "all" | "any";
|
|
183
|
+
ttlHours?: number | undefined;
|
|
184
|
+
} | undefined;
|
|
185
|
+
secrets?: {
|
|
186
|
+
dir?: string | undefined;
|
|
187
|
+
file?: string | undefined;
|
|
188
|
+
} | undefined;
|
|
189
|
+
}>>;
|
|
190
|
+
export declare const S_CONFIG_UPDATED: Signal<void>;
|
|
191
|
+
export declare class ConfigService extends BaseService {
|
|
192
|
+
private configurations;
|
|
193
|
+
private dir;
|
|
194
|
+
private busy;
|
|
195
|
+
private retake;
|
|
196
|
+
private reportedNames;
|
|
197
|
+
private watchDebounceTimer;
|
|
198
|
+
private _lastConfigHash;
|
|
199
|
+
constructor(dir: string);
|
|
200
|
+
init(): Promise<void>;
|
|
201
|
+
getConfig(): void;
|
|
202
|
+
}
|
|
203
|
+
export {};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConfigService = exports.S_CONFIG_UPDATED = exports.REQ_DEPLOYMENT_CONFIG = exports.PROJECT_CONFIG_MODEL = void 0;
|
|
7
|
+
exports.projectNameProblem = projectNameProblem;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
11
|
+
const Signal_1 = require("../../signal/Signal");
|
|
12
|
+
const BaseService_1 = require("../BaseService");
|
|
13
|
+
const LogService_1 = require("../LogService");
|
|
14
|
+
const PasswordHash_1 = require("../helper/PasswordHash");
|
|
15
|
+
const _ProjectState = {
|
|
16
|
+
active: "",
|
|
17
|
+
$__active_values: ["blue", "green"],
|
|
18
|
+
lastDeployed: "",
|
|
19
|
+
$__lastDeployed_values: ["blue", "green"],
|
|
20
|
+
history: [{
|
|
21
|
+
slot: "",
|
|
22
|
+
$__slot_values: ["blue", "green"],
|
|
23
|
+
action: "",
|
|
24
|
+
$__action_values: ["deploy", "switch", "rollback", "restore"],
|
|
25
|
+
user: "",
|
|
26
|
+
at: 0,
|
|
27
|
+
}],
|
|
28
|
+
statusToken: "",
|
|
29
|
+
$__statusToken_optional: true,
|
|
30
|
+
};
|
|
31
|
+
const _TConfig = {
|
|
32
|
+
name: "",
|
|
33
|
+
destination: "",
|
|
34
|
+
description: "",
|
|
35
|
+
token: "",
|
|
36
|
+
unpack: true,
|
|
37
|
+
ignoreDirectoryClean: false,
|
|
38
|
+
backup: true,
|
|
39
|
+
install: true,
|
|
40
|
+
omitDev: false,
|
|
41
|
+
$__omitDev_optional: true,
|
|
42
|
+
migrate: false,
|
|
43
|
+
$__migrate_optional: true,
|
|
44
|
+
pm2: true,
|
|
45
|
+
pm2_attributes: [""],
|
|
46
|
+
$__pm2_attributes_optional: true,
|
|
47
|
+
chmod: 0,
|
|
48
|
+
$__chmod_optional: true,
|
|
49
|
+
email: [""],
|
|
50
|
+
$__email_optional: true,
|
|
51
|
+
phone: [""],
|
|
52
|
+
$__phone_optional: true,
|
|
53
|
+
liveness: "",
|
|
54
|
+
$__liveness_optional: true,
|
|
55
|
+
readiness: "",
|
|
56
|
+
$__readiness_optional: true,
|
|
57
|
+
config: {},
|
|
58
|
+
bluegreen: {
|
|
59
|
+
blue_config: {},
|
|
60
|
+
blue_pm2_attributes: [""],
|
|
61
|
+
$__blue_pm2_attributes_optional: true,
|
|
62
|
+
green_config: {},
|
|
63
|
+
green_pm2_attributes: [""],
|
|
64
|
+
$__green_pm2_attributes_optional: true,
|
|
65
|
+
on_switch: [""],
|
|
66
|
+
$__on_switch_optional: true,
|
|
67
|
+
},
|
|
68
|
+
$__bluegreen_optional: true,
|
|
69
|
+
nginx: {
|
|
70
|
+
config_dir: "",
|
|
71
|
+
$__config_dir_optional: true,
|
|
72
|
+
domain: "",
|
|
73
|
+
$__domain_optional: true,
|
|
74
|
+
upstream_name: "",
|
|
75
|
+
$__upstream_name_optional: true,
|
|
76
|
+
},
|
|
77
|
+
$__nginx_optional: true,
|
|
78
|
+
review: {
|
|
79
|
+
reviewers: [""],
|
|
80
|
+
mode: "",
|
|
81
|
+
$__mode_values: ["any", "all"],
|
|
82
|
+
ttlHours: 24,
|
|
83
|
+
$__ttlHours_optional: true,
|
|
84
|
+
},
|
|
85
|
+
$__review_optional: true,
|
|
86
|
+
secrets: {
|
|
87
|
+
dir: "",
|
|
88
|
+
$__dir_optional: true,
|
|
89
|
+
file: "",
|
|
90
|
+
$__file_optional: true,
|
|
91
|
+
},
|
|
92
|
+
$__secrets_optional: true,
|
|
93
|
+
};
|
|
94
|
+
const PROJECT_NAME = /^[a-z0-9][a-z0-9._-]{0,99}$/;
|
|
95
|
+
function projectNameProblem(name) {
|
|
96
|
+
if (typeof name !== "string" || name.length === 0)
|
|
97
|
+
return "the project has no \"name\"";
|
|
98
|
+
if (!PROJECT_NAME.test(name))
|
|
99
|
+
return `project name "${name}" is not allowed — lowercase letters, digits, ".", "_" and "-" only, starting with a letter or digit, up to 100 characters (e.g. "api.gateway.example.com")`;
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
exports.PROJECT_CONFIG_MODEL = _TConfig;
|
|
103
|
+
exports.REQ_DEPLOYMENT_CONFIG = new Signal_1.Req();
|
|
104
|
+
exports.S_CONFIG_UPDATED = new Signal_1.Signal();
|
|
105
|
+
class ConfigService extends BaseService_1.BaseService {
|
|
106
|
+
configurations = new Map();
|
|
107
|
+
dir;
|
|
108
|
+
busy = false;
|
|
109
|
+
retake = false;
|
|
110
|
+
reportedNames = new Set();
|
|
111
|
+
watchDebounceTimer = null;
|
|
112
|
+
_lastConfigHash = null;
|
|
113
|
+
constructor(dir) {
|
|
114
|
+
super("ConfigService");
|
|
115
|
+
this.dir = dir;
|
|
116
|
+
}
|
|
117
|
+
async init() {
|
|
118
|
+
super.init();
|
|
119
|
+
exports.REQ_DEPLOYMENT_CONFIG.listener = async (req) => this.configurations;
|
|
120
|
+
if (!fs_1.default.existsSync(this.dir))
|
|
121
|
+
fs_1.default.mkdirSync(this.dir, { recursive: true });
|
|
122
|
+
this.getConfig();
|
|
123
|
+
fs_1.default.watch(this.dir, (_eventType, filename) => {
|
|
124
|
+
if (!filename || !filename.endsWith(".json"))
|
|
125
|
+
return;
|
|
126
|
+
if (this.watchDebounceTimer)
|
|
127
|
+
clearTimeout(this.watchDebounceTimer);
|
|
128
|
+
this.watchDebounceTimer = setTimeout(() => {
|
|
129
|
+
this.watchDebounceTimer = null;
|
|
130
|
+
this.getConfig();
|
|
131
|
+
}, 200);
|
|
132
|
+
});
|
|
133
|
+
setInterval(() => this.getConfig(), 60_000).unref();
|
|
134
|
+
}
|
|
135
|
+
getConfig() {
|
|
136
|
+
if (this.busy) {
|
|
137
|
+
this.retake = true;
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.retake = false;
|
|
141
|
+
this.busy = true;
|
|
142
|
+
const temp = new Map();
|
|
143
|
+
let isError = false;
|
|
144
|
+
try {
|
|
145
|
+
const files = fs_1.default.readdirSync(this.dir);
|
|
146
|
+
for (let f of files) {
|
|
147
|
+
if (f.indexOf(".json") === -1)
|
|
148
|
+
continue;
|
|
149
|
+
try {
|
|
150
|
+
const file = fs_1.default.readFileSync(path_1.default.resolve(this.dir, f));
|
|
151
|
+
const config = JSON.parse(file.toString());
|
|
152
|
+
if (config?.name === undefined)
|
|
153
|
+
continue;
|
|
154
|
+
const nameProblem = projectNameProblem(config.name);
|
|
155
|
+
if (nameProblem) {
|
|
156
|
+
const key = f + "\0" + String(config.name);
|
|
157
|
+
if (!this.reportedNames.has(key)) {
|
|
158
|
+
this.reportedNames.add(key);
|
|
159
|
+
(0, LogService_1.logError)(`Deployer: ${f} ignored — ${nameProblem}`);
|
|
160
|
+
}
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
temp.set(config.name, config);
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
isError = true;
|
|
167
|
+
(0, LogService_1.logError)("Can't read config file: " + f, e);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (!isError) {
|
|
171
|
+
const hash = crypto_1.default.createHash("md5")
|
|
172
|
+
.update(JSON.stringify(Array.from(temp.entries())))
|
|
173
|
+
.digest("hex");
|
|
174
|
+
if (hash !== this._lastConfigHash) {
|
|
175
|
+
this._lastConfigHash = hash;
|
|
176
|
+
this.configurations = temp;
|
|
177
|
+
exports.S_CONFIG_UPDATED.invoke();
|
|
178
|
+
(0, LogService_1.logWarn)("Configurations updated");
|
|
179
|
+
const plain = Array.from(temp.values()).filter((c) => c?.name && !PasswordHash_1.PasswordHash.isHash(c.token)).map((c) => c.name);
|
|
180
|
+
if (plain.length)
|
|
181
|
+
(0, LogService_1.logError)(`Deployer: project token stored as plain text for ${plain.map(n => '"' + n + '"').join(", ")} — these projects can't be deployed; store a hash instead: npx bmfk project-token --hash`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
(0, LogService_1.logError)("Can't read config directory", e);
|
|
187
|
+
}
|
|
188
|
+
this.busy = false;
|
|
189
|
+
if (this.retake) {
|
|
190
|
+
this.retake = false;
|
|
191
|
+
this.getConfig();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.ConfigService = ConfigService;
|