@devbro/pashmak 0.1.28 → 0.1.30
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/dist/DatabaseServiceProvider.mjs +18 -3
- package/dist/DatabaseServiceProvider.mjs.map +1 -1
- package/dist/bin/DatabaseServiceProvider.cjs +60 -3
- package/dist/bin/app/console/DefaultCommand.cjs +11 -8
- package/dist/bin/app/console/KeyGenerateCommand.cjs +11 -8
- package/dist/bin/app/console/StartCommand.cjs +15 -12
- package/dist/bin/app/console/generate/GenerateApiDocsCommand.cjs +11 -8
- package/dist/bin/app/console/generate/GenerateControllerCommand.cjs +13 -10
- package/dist/bin/app/console/generate/index.cjs +13 -10
- package/dist/bin/app/console/index.cjs +28 -25
- package/dist/bin/app/console/migrate/GenerateMigrateCommand.cjs +14 -11
- package/dist/bin/app/console/migrate/MigrateCommand.cjs +14 -11
- package/dist/bin/app/console/migrate/MigrateRollbackCommand.cjs +13 -10
- package/dist/bin/app/console/migrate/index.cjs +19 -16
- package/dist/bin/app/console/queue/GenerateQueueMigrateCommand.cjs +14 -11
- package/dist/bin/cache.cjs +11 -8
- package/dist/bin/facades.cjs +11 -8
- package/dist/bin/factories.cjs +11 -8
- package/dist/bin/global.cjs +69 -0
- package/dist/bin/index.cjs +105 -42
- package/dist/bin/middlewares.cjs +11 -8
- package/dist/bin/queue.cjs +11 -8
- package/dist/bin/router.cjs +33 -0
- package/dist/global.d.mts +12 -0
- package/dist/global.mjs +45 -0
- package/dist/global.mjs.map +1 -0
- package/dist/router.d.mts +4 -2
- package/dist/router.mjs +32 -0
- package/dist/router.mjs.map +1 -1
- package/package.json +6 -1
package/dist/bin/index.cjs
CHANGED
|
@@ -544,13 +544,14 @@ var init_dist = __esm({
|
|
|
544
544
|
});
|
|
545
545
|
|
|
546
546
|
// src/router.mts
|
|
547
|
-
var import_neko_context, import_errors;
|
|
547
|
+
var import_neko_context, import_errors, import_neko_config;
|
|
548
548
|
var init_router = __esm({
|
|
549
549
|
"src/router.mts"() {
|
|
550
550
|
"use strict";
|
|
551
551
|
import_neko_context = require("@devbro/neko-context");
|
|
552
552
|
import_errors = require("@devbro/neko-http/errors");
|
|
553
553
|
init_dist();
|
|
554
|
+
import_neko_config = require("@devbro/neko-config");
|
|
554
555
|
init_dist();
|
|
555
556
|
}
|
|
556
557
|
});
|
|
@@ -634,8 +635,8 @@ var init_queue = __esm({
|
|
|
634
635
|
}
|
|
635
636
|
});
|
|
636
637
|
}, "processMessage");
|
|
637
|
-
constructor(
|
|
638
|
-
this.config = { ...this.config, ...
|
|
638
|
+
constructor(config11 = {}) {
|
|
639
|
+
this.config = { ...this.config, ...config11 };
|
|
639
640
|
this.repeater = (0, import_neko_helper.createRepeater)(
|
|
640
641
|
this.processMessage,
|
|
641
642
|
this.config.listen_interval * 1e3
|
|
@@ -747,7 +748,7 @@ var init_factories = __esm({
|
|
|
747
748
|
});
|
|
748
749
|
|
|
749
750
|
// src/facades.mts
|
|
750
|
-
var import_neko_scheduler, import_neko_helper2, import_neko_context3, import_neko_storage2, import_neko_mailer2,
|
|
751
|
+
var import_neko_scheduler, import_neko_helper2, import_neko_context3, import_neko_storage2, import_neko_mailer2, import_neko_config2, import_clipanion, yup, import_neko_logger, import_neko_cache2, import_neko_queue2, router, scheduler, db, storage, cli, httpServer, logger, mailer, queue, cache;
|
|
751
752
|
var init_facades = __esm({
|
|
752
753
|
"src/facades.mts"() {
|
|
753
754
|
"use strict";
|
|
@@ -757,7 +758,7 @@ var init_facades = __esm({
|
|
|
757
758
|
import_neko_context3 = require("@devbro/neko-context");
|
|
758
759
|
import_neko_storage2 = require("@devbro/neko-storage");
|
|
759
760
|
import_neko_mailer2 = require("@devbro/neko-mailer");
|
|
760
|
-
|
|
761
|
+
import_neko_config2 = require("@devbro/neko-config");
|
|
761
762
|
import_clipanion = require("clipanion");
|
|
762
763
|
init_http();
|
|
763
764
|
init_http();
|
|
@@ -780,7 +781,7 @@ var init_facades = __esm({
|
|
|
780
781
|
});
|
|
781
782
|
db = /* @__PURE__ */ __name((label = "default") => (0, import_neko_context3.ctx)().getOrThrow(["database", label]), "db");
|
|
782
783
|
storage = (0, import_neko_helper2.createSingleton)((label = "default") => {
|
|
783
|
-
let storage_config =
|
|
784
|
+
let storage_config = import_neko_config2.config.get(["storages", label].join("."));
|
|
784
785
|
const provider = import_neko_storage2.StorageProviderFactory.create(
|
|
785
786
|
storage_config.provider,
|
|
786
787
|
storage_config.config
|
|
@@ -831,7 +832,7 @@ var init_facades = __esm({
|
|
|
831
832
|
return server;
|
|
832
833
|
});
|
|
833
834
|
logger = (0, import_neko_helper2.createSingleton)((label) => {
|
|
834
|
-
const logger_config =
|
|
835
|
+
const logger_config = import_neko_config2.config.get(["loggers", label].join("."));
|
|
835
836
|
const rc = new import_neko_logger.Logger(logger_config);
|
|
836
837
|
rc.setExtrasFunction((message) => {
|
|
837
838
|
message.requestId = (0, import_neko_context3.ctxSafe)()?.get("requestId") || "N/A";
|
|
@@ -840,7 +841,7 @@ var init_facades = __esm({
|
|
|
840
841
|
return rc;
|
|
841
842
|
});
|
|
842
843
|
mailer = (0, import_neko_helper2.createSingleton)((label) => {
|
|
843
|
-
const mailer_config =
|
|
844
|
+
const mailer_config = import_neko_config2.config.get(["mailer", label].join("."));
|
|
844
845
|
const provider = import_neko_mailer2.MailerProviderFactory.create(
|
|
845
846
|
mailer_config.provider,
|
|
846
847
|
mailer_config.config
|
|
@@ -849,7 +850,7 @@ var init_facades = __esm({
|
|
|
849
850
|
return rc;
|
|
850
851
|
});
|
|
851
852
|
queue = (0, import_neko_helper2.createSingleton)((label) => {
|
|
852
|
-
const queue_config =
|
|
853
|
+
const queue_config = import_neko_config2.config.get(["queues", label].join("."));
|
|
853
854
|
if (!queue_config) {
|
|
854
855
|
throw new Error(`Queue configuration for '${label}' not found`);
|
|
855
856
|
}
|
|
@@ -861,7 +862,7 @@ var init_facades = __esm({
|
|
|
861
862
|
return rc;
|
|
862
863
|
});
|
|
863
864
|
cache = (0, import_neko_helper2.createSingleton)((label) => {
|
|
864
|
-
const cache_config =
|
|
865
|
+
const cache_config = import_neko_config2.config.get(["caches", label].join("."));
|
|
865
866
|
if (!cache_config) {
|
|
866
867
|
throw new Error(`Cache configuration for '${label}' not found`);
|
|
867
868
|
}
|
|
@@ -875,7 +876,7 @@ var init_facades = __esm({
|
|
|
875
876
|
});
|
|
876
877
|
|
|
877
878
|
// src/app/console/migrate/MigrateCommand.mts
|
|
878
|
-
var import_clipanion2, import_neko_context4, import_path2, import_promises,
|
|
879
|
+
var import_clipanion2, import_neko_context4, import_path2, import_promises, import_neko_config3, MigrateCommand;
|
|
879
880
|
var init_MigrateCommand = __esm({
|
|
880
881
|
"src/app/console/migrate/MigrateCommand.mts"() {
|
|
881
882
|
"use strict";
|
|
@@ -884,7 +885,7 @@ var init_MigrateCommand = __esm({
|
|
|
884
885
|
import_neko_context4 = require("@devbro/neko-context");
|
|
885
886
|
import_path2 = __toESM(require("path"), 1);
|
|
886
887
|
import_promises = __toESM(require("fs/promises"), 1);
|
|
887
|
-
|
|
888
|
+
import_neko_config3 = require("@devbro/neko-config");
|
|
888
889
|
MigrateCommand = class extends import_clipanion2.Command {
|
|
889
890
|
static {
|
|
890
891
|
__name(this, "MigrateCommand");
|
|
@@ -910,7 +911,7 @@ var init_MigrateCommand = __esm({
|
|
|
910
911
|
parts: [],
|
|
911
912
|
bindings: []
|
|
912
913
|
});
|
|
913
|
-
const migrationsDir2 =
|
|
914
|
+
const migrationsDir2 = import_neko_config3.config.get("migration.path");
|
|
914
915
|
for (const migration_record of existing_migrations) {
|
|
915
916
|
logger().info(`rolling back ${migration_record.filename}`);
|
|
916
917
|
try {
|
|
@@ -941,7 +942,7 @@ var init_MigrateCommand = __esm({
|
|
|
941
942
|
blueprint.integer("batch");
|
|
942
943
|
});
|
|
943
944
|
}
|
|
944
|
-
const migrationsDir =
|
|
945
|
+
const migrationsDir = import_neko_config3.config.get("migration.path");
|
|
945
946
|
let files = [];
|
|
946
947
|
const dirEntries = await import_promises.default.readdir(migrationsDir);
|
|
947
948
|
files = dirEntries.filter((entry) => entry.endsWith(".ts") || entry.endsWith(".js")).sort();
|
|
@@ -988,7 +989,7 @@ var init_MigrateCommand = __esm({
|
|
|
988
989
|
});
|
|
989
990
|
|
|
990
991
|
// src/app/console/migrate/GenerateMigrateCommand.mts
|
|
991
|
-
var import_clipanion3, import_change_case_all, import_path3, fs2,
|
|
992
|
+
var import_clipanion3, import_change_case_all, import_path3, fs2, import_neko_config4, import_handlebars, import_url, import_meta, GenerateMigrateCommand;
|
|
992
993
|
var init_GenerateMigrateCommand = __esm({
|
|
993
994
|
"src/app/console/migrate/GenerateMigrateCommand.mts"() {
|
|
994
995
|
"use strict";
|
|
@@ -997,7 +998,7 @@ var init_GenerateMigrateCommand = __esm({
|
|
|
997
998
|
import_change_case_all = require("change-case-all");
|
|
998
999
|
import_path3 = __toESM(require("path"), 1);
|
|
999
1000
|
fs2 = __toESM(require("fs/promises"), 1);
|
|
1000
|
-
|
|
1001
|
+
import_neko_config4 = require("@devbro/neko-config");
|
|
1001
1002
|
import_handlebars = __toESM(require("handlebars"), 1);
|
|
1002
1003
|
import_url = require("url");
|
|
1003
1004
|
import_meta = {};
|
|
@@ -1022,7 +1023,7 @@ var init_GenerateMigrateCommand = __esm({
|
|
|
1022
1023
|
const filename = `${year}_${month}_${day}_${secondsOfDay}_${fixed_name}.ts`;
|
|
1023
1024
|
this.context.stdout.write(`creating migration file ${filename}
|
|
1024
1025
|
`);
|
|
1025
|
-
await fs2.mkdir(
|
|
1026
|
+
await fs2.mkdir(import_neko_config4.config.get("migration.path"), { recursive: true });
|
|
1026
1027
|
let dirname = typeof __dirname === "string" ? __dirname : void 0;
|
|
1027
1028
|
if (!dirname) {
|
|
1028
1029
|
dirname = import_path3.default.dirname((0, import_url.fileURLToPath)(import_meta.url));
|
|
@@ -1035,7 +1036,7 @@ var init_GenerateMigrateCommand = __esm({
|
|
|
1035
1036
|
tableName: import_change_case_all.Case.snake(this.name)
|
|
1036
1037
|
});
|
|
1037
1038
|
await fs2.writeFile(
|
|
1038
|
-
import_path3.default.join(
|
|
1039
|
+
import_path3.default.join(import_neko_config4.config.get("migration.path"), filename),
|
|
1039
1040
|
template
|
|
1040
1041
|
);
|
|
1041
1042
|
}
|
|
@@ -2197,7 +2198,7 @@ var require_lib = __commonJS({
|
|
|
2197
2198
|
});
|
|
2198
2199
|
|
|
2199
2200
|
// src/app/console/migrate/MigrateRollbackCommand.mts
|
|
2200
|
-
var import_clipanion4, import_neko_context5, import_path4, import_promises2,
|
|
2201
|
+
var import_clipanion4, import_neko_context5, import_path4, import_promises2, import_neko_config5, t, MigrateRollbackCommand;
|
|
2201
2202
|
var init_MigrateRollbackCommand = __esm({
|
|
2202
2203
|
"src/app/console/migrate/MigrateRollbackCommand.mts"() {
|
|
2203
2204
|
"use strict";
|
|
@@ -2206,7 +2207,7 @@ var init_MigrateRollbackCommand = __esm({
|
|
|
2206
2207
|
import_neko_context5 = require("@devbro/neko-context");
|
|
2207
2208
|
import_path4 = __toESM(require("path"), 1);
|
|
2208
2209
|
import_promises2 = __toESM(require("fs/promises"), 1);
|
|
2209
|
-
|
|
2210
|
+
import_neko_config5 = require("@devbro/neko-config");
|
|
2210
2211
|
t = __toESM(require_lib(), 1);
|
|
2211
2212
|
MigrateRollbackCommand = class extends import_clipanion4.Command {
|
|
2212
2213
|
static {
|
|
@@ -2221,7 +2222,7 @@ var init_MigrateRollbackCommand = __esm({
|
|
|
2221
2222
|
await import_neko_context5.context_provider.run(async () => {
|
|
2222
2223
|
const db2 = db();
|
|
2223
2224
|
const schema = db2.getSchema();
|
|
2224
|
-
const migrationsDir =
|
|
2225
|
+
const migrationsDir = import_neko_config5.config.get("migration.path");
|
|
2225
2226
|
let files = [];
|
|
2226
2227
|
const dirEntries = await import_promises2.default.readdir(migrationsDir);
|
|
2227
2228
|
files = dirEntries.filter((entry) => entry.endsWith(".ts")).sort();
|
|
@@ -2260,12 +2261,12 @@ var init_migrate = __esm({
|
|
|
2260
2261
|
});
|
|
2261
2262
|
|
|
2262
2263
|
// src/app/console/StartCommand.mts
|
|
2263
|
-
var import_clipanion5,
|
|
2264
|
+
var import_clipanion5, import_neko_config6, import_neko_sql, StartCommand;
|
|
2264
2265
|
var init_StartCommand = __esm({
|
|
2265
2266
|
"src/app/console/StartCommand.mts"() {
|
|
2266
2267
|
"use strict";
|
|
2267
2268
|
import_clipanion5 = require("clipanion");
|
|
2268
|
-
|
|
2269
|
+
import_neko_config6 = require("@devbro/neko-config");
|
|
2269
2270
|
init_facades();
|
|
2270
2271
|
import_neko_sql = require("@devbro/neko-sql");
|
|
2271
2272
|
StartCommand = class extends import_clipanion5.Command {
|
|
@@ -2294,16 +2295,16 @@ var init_StartCommand = __esm({
|
|
|
2294
2295
|
scheduler().start();
|
|
2295
2296
|
}
|
|
2296
2297
|
if (this.queue || this.all) {
|
|
2297
|
-
const config_queues =
|
|
2298
|
+
const config_queues = import_neko_config6.config.get("queues");
|
|
2298
2299
|
for (const [name, conf] of Object.entries(config_queues)) {
|
|
2299
2300
|
queue(name).start();
|
|
2300
2301
|
}
|
|
2301
2302
|
}
|
|
2302
2303
|
if (this.http || this.all) {
|
|
2303
2304
|
const server = httpServer();
|
|
2304
|
-
await server.listen(
|
|
2305
|
+
await server.listen(import_neko_config6.config.get("port"), () => {
|
|
2305
2306
|
logger().info(
|
|
2306
|
-
"Server is running on http://localhost:" +
|
|
2307
|
+
"Server is running on http://localhost:" + import_neko_config6.config.get("port")
|
|
2307
2308
|
);
|
|
2308
2309
|
});
|
|
2309
2310
|
}
|
|
@@ -2440,7 +2441,7 @@ ${key}=${value}`;
|
|
|
2440
2441
|
});
|
|
2441
2442
|
|
|
2442
2443
|
// src/app/console/generate/GenerateControllerCommand.mts
|
|
2443
|
-
var import_clipanion8, import_change_case_all2, import_path6, fs5,
|
|
2444
|
+
var import_clipanion8, import_change_case_all2, import_path6, fs5, import_neko_config7, import_handlebars2, import_url2, import_pluralize, import_meta2, GenerateControllerCommand;
|
|
2444
2445
|
var init_GenerateControllerCommand = __esm({
|
|
2445
2446
|
"src/app/console/generate/GenerateControllerCommand.mts"() {
|
|
2446
2447
|
"use strict";
|
|
@@ -2449,7 +2450,7 @@ var init_GenerateControllerCommand = __esm({
|
|
|
2449
2450
|
import_change_case_all2 = require("change-case-all");
|
|
2450
2451
|
import_path6 = __toESM(require("path"), 1);
|
|
2451
2452
|
fs5 = __toESM(require("fs/promises"), 1);
|
|
2452
|
-
|
|
2453
|
+
import_neko_config7 = require("@devbro/neko-config");
|
|
2453
2454
|
import_handlebars2 = __toESM(require("handlebars"), 1);
|
|
2454
2455
|
import_url2 = require("url");
|
|
2455
2456
|
import_pluralize = __toESM(require("pluralize"), 1);
|
|
@@ -2476,7 +2477,7 @@ var init_GenerateControllerCommand = __esm({
|
|
|
2476
2477
|
const filename = `${import_change_case_all2.Case.capital(this.name)}Controller.ts`;
|
|
2477
2478
|
this.context.stdout.write(`creating migration file ${filename}
|
|
2478
2479
|
`);
|
|
2479
|
-
await fs5.mkdir(
|
|
2480
|
+
await fs5.mkdir(import_neko_config7.config.get("migration.path"), { recursive: true });
|
|
2480
2481
|
let dirname = typeof __dirname === "string" ? __dirname : void 0;
|
|
2481
2482
|
if (!dirname) {
|
|
2482
2483
|
dirname = import_path6.default.dirname((0, import_url2.fileURLToPath)(import_meta2.url));
|
|
@@ -2745,7 +2746,7 @@ var init_CreateProjectCommand = __esm({
|
|
|
2745
2746
|
});
|
|
2746
2747
|
|
|
2747
2748
|
// src/app/console/queue/GenerateQueueMigrateCommand.mts
|
|
2748
|
-
var import_clipanion11, import_change_case_all4, import_path9, fs8,
|
|
2749
|
+
var import_clipanion11, import_change_case_all4, import_path9, fs8, import_neko_config8, import_handlebars4, import_url4, import_meta4, GenerateQueueMigrateCommand;
|
|
2749
2750
|
var init_GenerateQueueMigrateCommand = __esm({
|
|
2750
2751
|
"src/app/console/queue/GenerateQueueMigrateCommand.mts"() {
|
|
2751
2752
|
"use strict";
|
|
@@ -2754,7 +2755,7 @@ var init_GenerateQueueMigrateCommand = __esm({
|
|
|
2754
2755
|
import_change_case_all4 = require("change-case-all");
|
|
2755
2756
|
import_path9 = __toESM(require("path"), 1);
|
|
2756
2757
|
fs8 = __toESM(require("fs/promises"), 1);
|
|
2757
|
-
|
|
2758
|
+
import_neko_config8 = require("@devbro/neko-config");
|
|
2758
2759
|
import_handlebars4 = __toESM(require("handlebars"), 1);
|
|
2759
2760
|
import_url4 = require("url");
|
|
2760
2761
|
import_meta4 = {};
|
|
@@ -2776,7 +2777,7 @@ var init_GenerateQueueMigrateCommand = __esm({
|
|
|
2776
2777
|
const filename = `${year}_${month}_${day}_${secondsOfDay}_${fixed_name}.ts`;
|
|
2777
2778
|
this.context.stdout.write(`creating migration file ${filename}
|
|
2778
2779
|
`);
|
|
2779
|
-
await fs8.mkdir(
|
|
2780
|
+
await fs8.mkdir(import_neko_config8.config.get("migration.path"), { recursive: true });
|
|
2780
2781
|
let dirname = typeof __dirname === "string" ? __dirname : void 0;
|
|
2781
2782
|
if (!dirname) {
|
|
2782
2783
|
dirname = import_path9.default.dirname((0, import_url4.fileURLToPath)(import_meta4.url));
|
|
@@ -2789,7 +2790,7 @@ var init_GenerateQueueMigrateCommand = __esm({
|
|
|
2789
2790
|
tableName: import_change_case_all4.Case.snake(this.name)
|
|
2790
2791
|
});
|
|
2791
2792
|
await fs8.writeFile(
|
|
2792
|
-
import_path9.default.join(
|
|
2793
|
+
import_path9.default.join(import_neko_config8.config.get("migration.path"), filename),
|
|
2793
2794
|
template
|
|
2794
2795
|
);
|
|
2795
2796
|
}
|
|
@@ -2828,12 +2829,59 @@ var init_console = __esm({
|
|
|
2828
2829
|
}
|
|
2829
2830
|
});
|
|
2830
2831
|
|
|
2832
|
+
// src/global.mts
|
|
2833
|
+
var Global;
|
|
2834
|
+
var init_global = __esm({
|
|
2835
|
+
"src/global.mts"() {
|
|
2836
|
+
"use strict";
|
|
2837
|
+
Global = class _Global {
|
|
2838
|
+
static {
|
|
2839
|
+
__name(this, "Global");
|
|
2840
|
+
}
|
|
2841
|
+
static _vars = {};
|
|
2842
|
+
static set(key, value) {
|
|
2843
|
+
this._vars[_Global.generateInternalKey(key)] = value;
|
|
2844
|
+
}
|
|
2845
|
+
static get(key) {
|
|
2846
|
+
return this._vars[_Global.generateInternalKey(key)];
|
|
2847
|
+
}
|
|
2848
|
+
static getOrThrow(key) {
|
|
2849
|
+
const rc = this.get(key);
|
|
2850
|
+
if (rc === void 0) {
|
|
2851
|
+
throw new Error(
|
|
2852
|
+
`Key ${_Global.generateInternalKey(key)} not found in Global`
|
|
2853
|
+
);
|
|
2854
|
+
}
|
|
2855
|
+
return rc;
|
|
2856
|
+
}
|
|
2857
|
+
static generateInternalKey(key) {
|
|
2858
|
+
let new_key = "";
|
|
2859
|
+
if (Array.isArray(key)) {
|
|
2860
|
+
new_key = key.join(".");
|
|
2861
|
+
} else {
|
|
2862
|
+
new_key = key;
|
|
2863
|
+
}
|
|
2864
|
+
return new_key;
|
|
2865
|
+
}
|
|
2866
|
+
static has(key) {
|
|
2867
|
+
return _Global.generateInternalKey(key) in _Global._vars;
|
|
2868
|
+
}
|
|
2869
|
+
static delete(key) {
|
|
2870
|
+
delete _Global._vars[_Global.generateInternalKey(key)];
|
|
2871
|
+
}
|
|
2872
|
+
static keys() {
|
|
2873
|
+
return Object.keys(_Global._vars);
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
}
|
|
2877
|
+
});
|
|
2878
|
+
|
|
2831
2879
|
// src/DatabaseServiceProvider.mts
|
|
2832
2880
|
var DatabaseServiceProvider_exports = {};
|
|
2833
2881
|
__export(DatabaseServiceProvider_exports, {
|
|
2834
2882
|
DatabaseServiceProvider: () => DatabaseServiceProvider
|
|
2835
2883
|
});
|
|
2836
|
-
var import_neko_sql2, import_neko_orm, import_neko_context6,
|
|
2884
|
+
var import_neko_sql2, import_neko_orm, import_neko_context6, import_neko_config9, DatabaseServiceProvider;
|
|
2837
2885
|
var init_DatabaseServiceProvider = __esm({
|
|
2838
2886
|
"src/DatabaseServiceProvider.mts"() {
|
|
2839
2887
|
"use strict";
|
|
@@ -2841,13 +2889,14 @@ var init_DatabaseServiceProvider = __esm({
|
|
|
2841
2889
|
import_neko_sql2 = require("@devbro/neko-sql");
|
|
2842
2890
|
import_neko_orm = require("@devbro/neko-orm");
|
|
2843
2891
|
import_neko_context6 = require("@devbro/neko-context");
|
|
2844
|
-
|
|
2892
|
+
import_neko_config9 = require("@devbro/neko-config");
|
|
2893
|
+
init_global();
|
|
2845
2894
|
DatabaseServiceProvider = class _DatabaseServiceProvider extends Middleware {
|
|
2846
2895
|
static {
|
|
2847
2896
|
__name(this, "DatabaseServiceProvider");
|
|
2848
2897
|
}
|
|
2849
2898
|
async call(req, res, next) {
|
|
2850
|
-
const db_configs =
|
|
2899
|
+
const db_configs = import_neko_config9.config.get("databases");
|
|
2851
2900
|
const conns = [];
|
|
2852
2901
|
try {
|
|
2853
2902
|
for (const [name, db_config] of Object.entries(db_configs)) {
|
|
@@ -2855,9 +2904,23 @@ var init_DatabaseServiceProvider = __esm({
|
|
|
2855
2904
|
(0, import_neko_context6.ctx)().set(["database", name], conn);
|
|
2856
2905
|
conns.push(conn);
|
|
2857
2906
|
}
|
|
2858
|
-
import_neko_orm.BaseModel.setConnection(
|
|
2859
|
-
|
|
2860
|
-
|
|
2907
|
+
import_neko_orm.BaseModel.setConnection(async () => {
|
|
2908
|
+
const key = ["database", "default"];
|
|
2909
|
+
let rc = (0, import_neko_context6.ctx)().get(key);
|
|
2910
|
+
if ((0, import_neko_context6.ctx)().has(key)) {
|
|
2911
|
+
rc = (0, import_neko_context6.ctx)().get(key);
|
|
2912
|
+
} else if (Global.has(key)) {
|
|
2913
|
+
rc = Global.get(key);
|
|
2914
|
+
} else {
|
|
2915
|
+
rc = await this.getConnection(db_configs["default"]);
|
|
2916
|
+
try {
|
|
2917
|
+
(0, import_neko_context6.ctx)().set(key, rc);
|
|
2918
|
+
} catch {
|
|
2919
|
+
Global.set(key, rc);
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
return rc;
|
|
2923
|
+
});
|
|
2861
2924
|
await next();
|
|
2862
2925
|
} finally {
|
|
2863
2926
|
for (const conn of conns) {
|
|
@@ -2889,16 +2952,16 @@ var init_DatabaseServiceProvider = __esm({
|
|
|
2889
2952
|
var index_exports = {};
|
|
2890
2953
|
__export(index_exports, {
|
|
2891
2954
|
bootstrap: () => bootstrap,
|
|
2892
|
-
config: () =>
|
|
2955
|
+
config: () => import_neko_config10.config
|
|
2893
2956
|
});
|
|
2894
2957
|
module.exports = __toCommonJS(index_exports);
|
|
2895
2958
|
var import_neko_context7 = require("@devbro/neko-context");
|
|
2896
2959
|
init_dist();
|
|
2897
|
-
var
|
|
2960
|
+
var import_neko_config10 = require("@devbro/neko-config");
|
|
2898
2961
|
async function bootstrap(options) {
|
|
2899
2962
|
console.log("Bootstrapping application...");
|
|
2900
2963
|
console.log(`Root directory: ${options.root_dir}`);
|
|
2901
|
-
|
|
2964
|
+
import_neko_config10.config.load(options.config_data || {});
|
|
2902
2965
|
console.log("Loading application modules...");
|
|
2903
2966
|
await Promise.resolve().then(() => (init_console(), console_exports));
|
|
2904
2967
|
console.log("Loading Database Provider ...");
|
package/dist/bin/middlewares.cjs
CHANGED
|
@@ -456,13 +456,16 @@ var Router = class {
|
|
|
456
456
|
}
|
|
457
457
|
};
|
|
458
458
|
|
|
459
|
+
// src/router.mts
|
|
460
|
+
var import_neko_config = require("@devbro/neko-config");
|
|
461
|
+
|
|
459
462
|
// src/facades.mts
|
|
460
463
|
var import_neko_scheduler = require("@devbro/neko-scheduler");
|
|
461
464
|
var import_neko_helper2 = require("@devbro/neko-helper");
|
|
462
465
|
var import_neko_context3 = require("@devbro/neko-context");
|
|
463
466
|
var import_neko_storage2 = require("@devbro/neko-storage");
|
|
464
467
|
var import_neko_mailer2 = require("@devbro/neko-mailer");
|
|
465
|
-
var
|
|
468
|
+
var import_neko_config2 = require("@devbro/neko-config");
|
|
466
469
|
var import_clipanion = require("clipanion");
|
|
467
470
|
|
|
468
471
|
// src/http.mts
|
|
@@ -542,8 +545,8 @@ var DatabaseTransport = class {
|
|
|
542
545
|
}
|
|
543
546
|
});
|
|
544
547
|
}, "processMessage");
|
|
545
|
-
constructor(
|
|
546
|
-
this.config = { ...this.config, ...
|
|
548
|
+
constructor(config3 = {}) {
|
|
549
|
+
this.config = { ...this.config, ...config3 };
|
|
547
550
|
this.repeater = (0, import_neko_helper.createRepeater)(
|
|
548
551
|
this.processMessage,
|
|
549
552
|
this.config.listen_interval * 1e3
|
|
@@ -660,7 +663,7 @@ var scheduler = (0, import_neko_helper2.createSingleton)(() => {
|
|
|
660
663
|
});
|
|
661
664
|
var db = /* @__PURE__ */ __name((label = "default") => (0, import_neko_context3.ctx)().getOrThrow(["database", label]), "db");
|
|
662
665
|
var storage = (0, import_neko_helper2.createSingleton)((label = "default") => {
|
|
663
|
-
let storage_config =
|
|
666
|
+
let storage_config = import_neko_config2.config.get(["storages", label].join("."));
|
|
664
667
|
const provider = import_neko_storage2.StorageProviderFactory.create(
|
|
665
668
|
storage_config.provider,
|
|
666
669
|
storage_config.config
|
|
@@ -711,7 +714,7 @@ var httpServer = (0, import_neko_helper2.createSingleton)(() => {
|
|
|
711
714
|
return server;
|
|
712
715
|
});
|
|
713
716
|
var logger = (0, import_neko_helper2.createSingleton)((label) => {
|
|
714
|
-
const logger_config =
|
|
717
|
+
const logger_config = import_neko_config2.config.get(["loggers", label].join("."));
|
|
715
718
|
const rc = new import_neko_logger.Logger(logger_config);
|
|
716
719
|
rc.setExtrasFunction((message) => {
|
|
717
720
|
message.requestId = (0, import_neko_context3.ctxSafe)()?.get("requestId") || "N/A";
|
|
@@ -720,7 +723,7 @@ var logger = (0, import_neko_helper2.createSingleton)((label) => {
|
|
|
720
723
|
return rc;
|
|
721
724
|
});
|
|
722
725
|
var mailer = (0, import_neko_helper2.createSingleton)((label) => {
|
|
723
|
-
const mailer_config =
|
|
726
|
+
const mailer_config = import_neko_config2.config.get(["mailer", label].join("."));
|
|
724
727
|
const provider = import_neko_mailer2.MailerProviderFactory.create(
|
|
725
728
|
mailer_config.provider,
|
|
726
729
|
mailer_config.config
|
|
@@ -729,7 +732,7 @@ var mailer = (0, import_neko_helper2.createSingleton)((label) => {
|
|
|
729
732
|
return rc;
|
|
730
733
|
});
|
|
731
734
|
var queue = (0, import_neko_helper2.createSingleton)((label) => {
|
|
732
|
-
const queue_config =
|
|
735
|
+
const queue_config = import_neko_config2.config.get(["queues", label].join("."));
|
|
733
736
|
if (!queue_config) {
|
|
734
737
|
throw new Error(`Queue configuration for '${label}' not found`);
|
|
735
738
|
}
|
|
@@ -741,7 +744,7 @@ var queue = (0, import_neko_helper2.createSingleton)((label) => {
|
|
|
741
744
|
return rc;
|
|
742
745
|
});
|
|
743
746
|
var cache = (0, import_neko_helper2.createSingleton)((label) => {
|
|
744
|
-
const cache_config =
|
|
747
|
+
const cache_config = import_neko_config2.config.get(["caches", label].join("."));
|
|
745
748
|
if (!cache_config) {
|
|
746
749
|
throw new Error(`Cache configuration for '${label}' not found`);
|
|
747
750
|
}
|
package/dist/bin/queue.cjs
CHANGED
|
@@ -456,13 +456,16 @@ var Router = class {
|
|
|
456
456
|
}
|
|
457
457
|
};
|
|
458
458
|
|
|
459
|
+
// src/router.mts
|
|
460
|
+
var import_neko_config = require("@devbro/neko-config");
|
|
461
|
+
|
|
459
462
|
// src/facades.mts
|
|
460
463
|
var import_neko_scheduler = require("@devbro/neko-scheduler");
|
|
461
464
|
var import_neko_helper = require("@devbro/neko-helper");
|
|
462
465
|
var import_neko_context2 = require("@devbro/neko-context");
|
|
463
466
|
var import_neko_storage2 = require("@devbro/neko-storage");
|
|
464
467
|
var import_neko_mailer2 = require("@devbro/neko-mailer");
|
|
465
|
-
var
|
|
468
|
+
var import_neko_config2 = require("@devbro/neko-config");
|
|
466
469
|
var import_clipanion = require("clipanion");
|
|
467
470
|
|
|
468
471
|
// src/http.mts
|
|
@@ -557,7 +560,7 @@ var scheduler = (0, import_neko_helper.createSingleton)(() => {
|
|
|
557
560
|
});
|
|
558
561
|
var db = /* @__PURE__ */ __name((label = "default") => (0, import_neko_context2.ctx)().getOrThrow(["database", label]), "db");
|
|
559
562
|
var storage = (0, import_neko_helper.createSingleton)((label = "default") => {
|
|
560
|
-
let storage_config =
|
|
563
|
+
let storage_config = import_neko_config2.config.get(["storages", label].join("."));
|
|
561
564
|
const provider = import_neko_storage2.StorageProviderFactory.create(
|
|
562
565
|
storage_config.provider,
|
|
563
566
|
storage_config.config
|
|
@@ -608,7 +611,7 @@ var httpServer = (0, import_neko_helper.createSingleton)(() => {
|
|
|
608
611
|
return server;
|
|
609
612
|
});
|
|
610
613
|
var logger = (0, import_neko_helper.createSingleton)((label) => {
|
|
611
|
-
const logger_config =
|
|
614
|
+
const logger_config = import_neko_config2.config.get(["loggers", label].join("."));
|
|
612
615
|
const rc = new import_neko_logger.Logger(logger_config);
|
|
613
616
|
rc.setExtrasFunction((message) => {
|
|
614
617
|
message.requestId = (0, import_neko_context2.ctxSafe)()?.get("requestId") || "N/A";
|
|
@@ -617,7 +620,7 @@ var logger = (0, import_neko_helper.createSingleton)((label) => {
|
|
|
617
620
|
return rc;
|
|
618
621
|
});
|
|
619
622
|
var mailer = (0, import_neko_helper.createSingleton)((label) => {
|
|
620
|
-
const mailer_config =
|
|
623
|
+
const mailer_config = import_neko_config2.config.get(["mailer", label].join("."));
|
|
621
624
|
const provider = import_neko_mailer2.MailerProviderFactory.create(
|
|
622
625
|
mailer_config.provider,
|
|
623
626
|
mailer_config.config
|
|
@@ -626,7 +629,7 @@ var mailer = (0, import_neko_helper.createSingleton)((label) => {
|
|
|
626
629
|
return rc;
|
|
627
630
|
});
|
|
628
631
|
var queue = (0, import_neko_helper.createSingleton)((label) => {
|
|
629
|
-
const queue_config =
|
|
632
|
+
const queue_config = import_neko_config2.config.get(["queues", label].join("."));
|
|
630
633
|
if (!queue_config) {
|
|
631
634
|
throw new Error(`Queue configuration for '${label}' not found`);
|
|
632
635
|
}
|
|
@@ -638,7 +641,7 @@ var queue = (0, import_neko_helper.createSingleton)((label) => {
|
|
|
638
641
|
return rc;
|
|
639
642
|
});
|
|
640
643
|
var cache = (0, import_neko_helper.createSingleton)((label) => {
|
|
641
|
-
const cache_config =
|
|
644
|
+
const cache_config = import_neko_config2.config.get(["caches", label].join("."));
|
|
642
645
|
if (!cache_config) {
|
|
643
646
|
throw new Error(`Cache configuration for '${label}' not found`);
|
|
644
647
|
}
|
|
@@ -709,8 +712,8 @@ var DatabaseTransport = class {
|
|
|
709
712
|
}
|
|
710
713
|
});
|
|
711
714
|
}, "processMessage");
|
|
712
|
-
constructor(
|
|
713
|
-
this.config = { ...this.config, ...
|
|
715
|
+
constructor(config3 = {}) {
|
|
716
|
+
this.config = { ...this.config, ...config3 };
|
|
714
717
|
this.repeater = (0, import_neko_helper2.createRepeater)(
|
|
715
718
|
this.processMessage,
|
|
716
719
|
this.config.listen_interval * 1e3
|
package/dist/bin/router.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/router.mts
|
|
32
32
|
var router_exports = {};
|
|
33
33
|
__export(router_exports, {
|
|
34
|
+
ApiDocumentation: () => ApiDocumentation,
|
|
34
35
|
BaseController: () => BaseController,
|
|
35
36
|
CompiledRoute: () => CompiledRoute,
|
|
36
37
|
Controller: () => Controller,
|
|
@@ -594,6 +595,7 @@ async function runNext(middlewares, req, res, final) {
|
|
|
594
595
|
__name(runNext, "runNext");
|
|
595
596
|
|
|
596
597
|
// src/router.mts
|
|
598
|
+
var import_neko_config = require("@devbro/neko-config");
|
|
597
599
|
function Model(model, param_name = "id", model_field = "id") {
|
|
598
600
|
return createParamDecorator(async () => {
|
|
599
601
|
let rc = await model.findOne({
|
|
@@ -619,8 +621,39 @@ function ValidatedRequest(validationRules) {
|
|
|
619
621
|
});
|
|
620
622
|
}
|
|
621
623
|
__name(ValidatedRequest, "ValidatedRequest");
|
|
624
|
+
function ApiDocumentation(req, res) {
|
|
625
|
+
let open_api_url = import_neko_config.config.get("api_doc_url");
|
|
626
|
+
let html = `<!DOCTYPE html>
|
|
627
|
+
<html>
|
|
628
|
+
<head>
|
|
629
|
+
<title>Redoc</title>
|
|
630
|
+
<!-- needed for adaptive design -->
|
|
631
|
+
<meta charset="utf-8"/>
|
|
632
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
633
|
+
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
|
|
634
|
+
|
|
635
|
+
<!--
|
|
636
|
+
Redoc doesn't change outer page styles
|
|
637
|
+
-->
|
|
638
|
+
<style>
|
|
639
|
+
body {
|
|
640
|
+
margin: 0;
|
|
641
|
+
padding: 0;
|
|
642
|
+
}
|
|
643
|
+
</style>
|
|
644
|
+
</head>
|
|
645
|
+
<body>
|
|
646
|
+
<redoc spec-url='${open_api_url}'></redoc>
|
|
647
|
+
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> </script>
|
|
648
|
+
</body>
|
|
649
|
+
</html>`;
|
|
650
|
+
res.setHeader("Content-Type", "text/html");
|
|
651
|
+
return html;
|
|
652
|
+
}
|
|
653
|
+
__name(ApiDocumentation, "ApiDocumentation");
|
|
622
654
|
// Annotate the CommonJS export names for ESM import in node:
|
|
623
655
|
0 && (module.exports = {
|
|
656
|
+
ApiDocumentation,
|
|
624
657
|
BaseController,
|
|
625
658
|
CompiledRoute,
|
|
626
659
|
Controller,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare class Global {
|
|
2
|
+
static _vars: Record<string, any>;
|
|
3
|
+
static set(key: string | string[], value: any): void;
|
|
4
|
+
static get<T>(key: string | string[]): T | undefined;
|
|
5
|
+
static getOrThrow<T>(key: string | string[]): T;
|
|
6
|
+
static generateInternalKey(key: string | string[]): string;
|
|
7
|
+
static has(key: string | string[]): boolean;
|
|
8
|
+
static delete(key: string | string[]): void;
|
|
9
|
+
static keys(): string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { Global };
|
package/dist/global.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
class Global {
|
|
4
|
+
static {
|
|
5
|
+
__name(this, "Global");
|
|
6
|
+
}
|
|
7
|
+
static _vars = {};
|
|
8
|
+
static set(key, value) {
|
|
9
|
+
this._vars[Global.generateInternalKey(key)] = value;
|
|
10
|
+
}
|
|
11
|
+
static get(key) {
|
|
12
|
+
return this._vars[Global.generateInternalKey(key)];
|
|
13
|
+
}
|
|
14
|
+
static getOrThrow(key) {
|
|
15
|
+
const rc = this.get(key);
|
|
16
|
+
if (rc === void 0) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
`Key ${Global.generateInternalKey(key)} not found in Global`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return rc;
|
|
22
|
+
}
|
|
23
|
+
static generateInternalKey(key) {
|
|
24
|
+
let new_key = "";
|
|
25
|
+
if (Array.isArray(key)) {
|
|
26
|
+
new_key = key.join(".");
|
|
27
|
+
} else {
|
|
28
|
+
new_key = key;
|
|
29
|
+
}
|
|
30
|
+
return new_key;
|
|
31
|
+
}
|
|
32
|
+
static has(key) {
|
|
33
|
+
return Global.generateInternalKey(key) in Global._vars;
|
|
34
|
+
}
|
|
35
|
+
static delete(key) {
|
|
36
|
+
delete Global._vars[Global.generateInternalKey(key)];
|
|
37
|
+
}
|
|
38
|
+
static keys() {
|
|
39
|
+
return Object.keys(Global._vars);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
Global
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=global.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/global.mts"],"sourcesContent":["export class Global {\n static _vars: Record<string, any> = {};\n\n static set(key: string | string[], value: any) {\n this._vars[Global.generateInternalKey(key)] = value;\n }\n\n static get<T>(key: string | string[]): T | undefined {\n return this._vars[Global.generateInternalKey(key)] as T;\n }\n\n static getOrThrow<T>(key: string | string[]): T {\n const rc = this.get<T>(key);\n if (rc === undefined) {\n throw new Error(\n `Key ${Global.generateInternalKey(key)} not found in Global`,\n );\n }\n return rc;\n }\n\n static generateInternalKey(key: string | string[]) {\n let new_key = \"\";\n if (Array.isArray(key)) {\n new_key = key.join(\".\");\n } else {\n new_key = key;\n }\n return new_key;\n }\n\n static has(key: string | string[]): boolean {\n return Global.generateInternalKey(key) in Global._vars;\n }\n static delete(key: string | string[]) {\n delete Global._vars[Global.generateInternalKey(key)];\n }\n\n static keys() {\n return Object.keys(Global._vars);\n }\n}\n"],"mappings":";;AAAO,MAAM,OAAO;AAAA,EAApB,OAAoB;AAAA;AAAA;AAAA,EAClB,OAAO,QAA6B,CAAC;AAAA,EAErC,OAAO,IAAI,KAAwB,OAAY;AAC7C,SAAK,MAAM,OAAO,oBAAoB,GAAG,CAAC,IAAI;AAAA,EAChD;AAAA,EAEA,OAAO,IAAO,KAAuC;AACnD,WAAO,KAAK,MAAM,OAAO,oBAAoB,GAAG,CAAC;AAAA,EACnD;AAAA,EAEA,OAAO,WAAc,KAA2B;AAC9C,UAAM,KAAK,KAAK,IAAO,GAAG;AAC1B,QAAI,OAAO,QAAW;AACpB,YAAM,IAAI;AAAA,QACR,OAAO,OAAO,oBAAoB,GAAG,CAAC;AAAA,MACxC;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,oBAAoB,KAAwB;AACjD,QAAI,UAAU;AACd,QAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,gBAAU,IAAI,KAAK,GAAG;AAAA,IACxB,OAAO;AACL,gBAAU;AAAA,IACZ;AACA,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,IAAI,KAAiC;AAC1C,WAAO,OAAO,oBAAoB,GAAG,KAAK,OAAO;AAAA,EACnD;AAAA,EACA,OAAO,OAAO,KAAwB;AACpC,WAAO,OAAO,MAAM,OAAO,oBAAoB,GAAG,CAAC;AAAA,EACrD;AAAA,EAEA,OAAO,OAAO;AACZ,WAAO,OAAO,KAAK,OAAO,KAAK;AAAA,EACjC;AACF;","names":[]}
|