@devbro/pashmak 0.1.48 → 0.1.51
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.d.mts +5 -2
- package/dist/DatabaseServiceProvider.mjs +10 -3
- package/dist/DatabaseServiceProvider.mjs.map +1 -1
- package/dist/app/console/StartCommand.d.mts +1 -0
- package/dist/app/console/StartCommand.mjs +5 -2
- package/dist/app/console/StartCommand.mjs.map +1 -1
- package/dist/app/console/generate/GenerateApiDocsCommand.d.mts +34 -2
- package/dist/app/console/generate/GenerateApiDocsCommand.mjs +183 -100
- package/dist/app/console/generate/GenerateApiDocsCommand.mjs.map +1 -1
- package/dist/app/console/project/base_project/src/config/storages.ts.tpl +2 -2
- package/dist/bin/DatabaseServiceProvider.cjs +12 -2
- package/dist/bin/app/console/DefaultCommand.cjs +136 -69
- package/dist/bin/app/console/KeyGenerateCommand.cjs +136 -69
- package/dist/bin/app/console/StartCommand.cjs +141 -71
- package/dist/bin/app/console/generate/GenerateApiDocsCommand.cjs +320 -170
- package/dist/bin/app/console/generate/GenerateControllerCommand.cjs +136 -69
- package/dist/bin/app/console/generate/index.cjs +320 -170
- package/dist/bin/app/console/index.cjs +325 -172
- package/dist/bin/app/console/migrate/GenerateMigrateCommand.cjs +136 -69
- package/dist/bin/app/console/migrate/MigrateCommand.cjs +136 -69
- package/dist/bin/app/console/migrate/MigrateRollbackCommand.cjs +136 -69
- package/dist/bin/app/console/migrate/index.cjs +136 -69
- package/dist/bin/app/console/queue/GenerateQueueMigrateCommand.cjs +136 -69
- package/dist/bin/cache.cjs +136 -69
- package/dist/bin/facades.cjs +136 -69
- package/dist/bin/factories.cjs +136 -69
- package/dist/bin/http.cjs +136 -69
- package/dist/bin/index.cjs +338 -178
- package/dist/bin/middlewares.cjs +136 -69
- package/dist/bin/queue.cjs +136 -69
- package/dist/bin/router.cjs +3 -5
- package/dist/facades.d.mts +6 -6
- package/dist/facades.mjs +97 -58
- package/dist/facades.mjs.map +1 -1
- package/dist/factories.mjs +45 -2
- package/dist/factories.mjs.map +1 -1
- package/dist/http.mjs +1 -1
- package/dist/http.mjs.map +1 -1
- package/dist/queue.d.mts +1 -1
- package/dist/queue.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -77,6 +77,7 @@ var MiddlewareFactory = class {
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
// ../neko-router/dist/CompiledRoute.mjs
|
|
80
|
+
var import_neko_helper = require("@devbro/neko-helper");
|
|
80
81
|
var CompiledRoute = class {
|
|
81
82
|
static {
|
|
82
83
|
__name(this, "CompiledRoute");
|
|
@@ -97,7 +98,7 @@ var CompiledRoute = class {
|
|
|
97
98
|
for (const middleware of [...this.globalMiddlewares, ...this.route.getMiddlewares()]) {
|
|
98
99
|
if (middleware instanceof Middleware) {
|
|
99
100
|
this.middlewares.push(middleware);
|
|
100
|
-
} else if (
|
|
101
|
+
} else if ((0, import_neko_helper.isClass)(middleware)) {
|
|
101
102
|
this.middlewares.push(middleware.getInstance({}));
|
|
102
103
|
} else if (typeof middleware === "function") {
|
|
103
104
|
this.middlewares.push(MiddlewareFactory.create(middleware));
|
|
@@ -106,9 +107,6 @@ var CompiledRoute = class {
|
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
isClass(func) {
|
|
110
|
-
return typeof func === "function" && /^class\s/.test(Function.prototype.toString.call(func));
|
|
111
|
-
}
|
|
112
110
|
async run() {
|
|
113
111
|
return await this.runMiddlewares(this.middlewares, this.request, this.response);
|
|
114
112
|
}
|
|
@@ -244,7 +242,7 @@ var Route = class {
|
|
|
244
242
|
i = start;
|
|
245
243
|
} else if (char === "*") {
|
|
246
244
|
let start = i + 1;
|
|
247
|
-
while (start < path3.length && /[a-zA-Z0-9_
|
|
245
|
+
while (start < path3.length && /[a-zA-Z0-9_]/.test(path3[start])) {
|
|
248
246
|
start++;
|
|
249
247
|
}
|
|
250
248
|
tokens.push({ type: "WILDCARD", value: path3.slice(i + 1, start) });
|
|
@@ -455,7 +453,7 @@ var Router = class {
|
|
|
455
453
|
|
|
456
454
|
// src/facades.mts
|
|
457
455
|
var import_neko_scheduler = require("@devbro/neko-scheduler");
|
|
458
|
-
var
|
|
456
|
+
var import_neko_helper3 = require("@devbro/neko-helper");
|
|
459
457
|
var import_neko_context3 = require("@devbro/neko-context");
|
|
460
458
|
var import_neko_storage2 = require("@devbro/neko-storage");
|
|
461
459
|
var import_neko_mailer2 = require("@devbro/neko-mailer");
|
|
@@ -496,7 +494,7 @@ __export(queue_exports, {
|
|
|
496
494
|
DatabaseTransport: () => DatabaseTransport
|
|
497
495
|
});
|
|
498
496
|
__reExport(queue_exports, require("@devbro/neko-queue"));
|
|
499
|
-
var
|
|
497
|
+
var import_neko_helper2 = require("@devbro/neko-helper");
|
|
500
498
|
var import_neko_context2 = require("@devbro/neko-context");
|
|
501
499
|
var DatabaseTransport = class {
|
|
502
500
|
static {
|
|
@@ -557,7 +555,7 @@ var DatabaseTransport = class {
|
|
|
557
555
|
}, "processMessage");
|
|
558
556
|
constructor(config3 = {}) {
|
|
559
557
|
this.config = { ...this.config, ...config3 };
|
|
560
|
-
this.repeater = (0,
|
|
558
|
+
this.repeater = (0, import_neko_helper2.createRepeater)(
|
|
561
559
|
this.processMessage,
|
|
562
560
|
this.config.listen_interval * 1e3
|
|
563
561
|
);
|
|
@@ -625,6 +623,24 @@ import_neko_queue.QueueTransportFactory.register("database", (opt) => {
|
|
|
625
623
|
import_neko_queue.QueueTransportFactory.register("memory", (opt) => {
|
|
626
624
|
return new import_neko_queue.MemoryTransport(opt);
|
|
627
625
|
});
|
|
626
|
+
import_neko_queue.QueueTransportFactory.register("sqs", (opt) => {
|
|
627
|
+
return new import_neko_queue.AwsSqsTransport(opt);
|
|
628
|
+
});
|
|
629
|
+
import_neko_queue.QueueTransportFactory.register("amqp", (opt) => {
|
|
630
|
+
return new import_neko_queue.AmqpTransport(opt);
|
|
631
|
+
});
|
|
632
|
+
import_neko_queue.QueueTransportFactory.register("redis", (opt) => {
|
|
633
|
+
return new import_neko_queue.RedisTransport(opt);
|
|
634
|
+
});
|
|
635
|
+
import_neko_queue.QueueTransportFactory.register("async", (opt) => {
|
|
636
|
+
return new import_neko_queue.AsyncTransport();
|
|
637
|
+
});
|
|
638
|
+
import_neko_queue.QueueTransportFactory.register("azure_service_bus", (opt) => {
|
|
639
|
+
return new import_neko_queue.AzureServiceBusTransport(opt);
|
|
640
|
+
});
|
|
641
|
+
import_neko_queue.QueueTransportFactory.register("google_pubsub", (opt) => {
|
|
642
|
+
return new import_neko_queue.GooglePubSubTransport(opt);
|
|
643
|
+
});
|
|
628
644
|
var CacheProviderFactory = class _CacheProviderFactory {
|
|
629
645
|
static {
|
|
630
646
|
__name(this, "CacheProviderFactory");
|
|
@@ -655,32 +671,75 @@ import_neko_storage.StorageProviderFactory.register("local", (opt) => {
|
|
|
655
671
|
import_neko_storage.StorageProviderFactory.register("s3", (opt) => {
|
|
656
672
|
return new import_neko_storage.AWSS3StorageProvider(opt);
|
|
657
673
|
});
|
|
674
|
+
import_neko_storage.StorageProviderFactory.register("gcp", (opt) => {
|
|
675
|
+
return new import_neko_storage.GCPStorageProvider(opt);
|
|
676
|
+
});
|
|
677
|
+
import_neko_storage.StorageProviderFactory.register("azure", (opt) => {
|
|
678
|
+
return new import_neko_storage.AzureBlobStorageProvider(opt);
|
|
679
|
+
});
|
|
680
|
+
import_neko_storage.StorageProviderFactory.register("ftp", (opt) => {
|
|
681
|
+
return new import_neko_storage.FTPStorageProvider(opt);
|
|
682
|
+
});
|
|
683
|
+
import_neko_storage.StorageProviderFactory.register("sftp", (opt) => {
|
|
684
|
+
return new import_neko_storage.SFTPStorageProvider(opt);
|
|
685
|
+
});
|
|
658
686
|
|
|
659
687
|
// src/facades.mts
|
|
660
688
|
var import_neko_cache2 = require("@devbro/neko-cache");
|
|
661
689
|
var import_neko_queue2 = require("@devbro/neko-queue");
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
690
|
+
function wrapSingletonWithAccessors(singletonFn) {
|
|
691
|
+
let methodsInitialized = false;
|
|
692
|
+
const initializeMethods = /* @__PURE__ */ __name(() => {
|
|
693
|
+
if (methodsInitialized) return;
|
|
694
|
+
const defaultInstance = singletonFn();
|
|
695
|
+
const prototype = Object.getPrototypeOf(defaultInstance);
|
|
696
|
+
const methodNames = Object.getOwnPropertyNames(prototype).filter(
|
|
697
|
+
(name) => name !== "constructor" && typeof prototype[name] === "function"
|
|
698
|
+
);
|
|
699
|
+
for (const methodName of methodNames) {
|
|
700
|
+
singletonFn[methodName] = (...args) => {
|
|
701
|
+
const instance = singletonFn();
|
|
702
|
+
return instance[methodName](...args);
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
methodsInitialized = true;
|
|
706
|
+
}, "initializeMethods");
|
|
707
|
+
return new Proxy(singletonFn, {
|
|
708
|
+
get(target, prop, receiver) {
|
|
709
|
+
if (typeof prop === "string" && !Reflect.has(target, prop)) {
|
|
710
|
+
initializeMethods();
|
|
711
|
+
}
|
|
712
|
+
return Reflect.get(target, prop, receiver);
|
|
713
|
+
}
|
|
671
714
|
});
|
|
672
|
-
|
|
673
|
-
|
|
715
|
+
}
|
|
716
|
+
__name(wrapSingletonWithAccessors, "wrapSingletonWithAccessors");
|
|
717
|
+
var router = (0, import_neko_helper3.createSingleton)(() => new Router());
|
|
718
|
+
var scheduler = wrapSingletonWithAccessors(
|
|
719
|
+
(0, import_neko_helper3.createSingleton)(() => {
|
|
720
|
+
const rc = new import_neko_scheduler.Scheduler();
|
|
721
|
+
rc.setErrorHandler((err, job) => {
|
|
722
|
+
logger().error({
|
|
723
|
+
msg: "Scheduled job error",
|
|
724
|
+
err,
|
|
725
|
+
job_name: job.getName()
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
return rc;
|
|
729
|
+
})
|
|
730
|
+
);
|
|
674
731
|
var db = /* @__PURE__ */ __name((label = "default") => (0, import_neko_context3.ctx)().getOrThrow(["database", label]), "db");
|
|
675
|
-
var storage = (
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
732
|
+
var storage = wrapSingletonWithAccessors(
|
|
733
|
+
(0, import_neko_helper3.createSingleton)((label = "default") => {
|
|
734
|
+
let storage_config = import_neko_config.config.get(["storages", label].join("."));
|
|
735
|
+
const provider = import_neko_storage2.StorageProviderFactory.create(
|
|
736
|
+
storage_config.provider,
|
|
737
|
+
storage_config.config
|
|
738
|
+
);
|
|
739
|
+
return new import_neko_storage2.Storage(provider);
|
|
740
|
+
})
|
|
741
|
+
);
|
|
742
|
+
var cli = (0, import_neko_helper3.createSingleton)(() => {
|
|
684
743
|
const [node, app, ...args] = process.argv;
|
|
685
744
|
return new import_clipanion.Cli({
|
|
686
745
|
binaryLabel: `My Application`,
|
|
@@ -688,52 +747,60 @@ var cli = (0, import_neko_helper2.createSingleton)(() => {
|
|
|
688
747
|
binaryVersion: `1.0.0`
|
|
689
748
|
});
|
|
690
749
|
});
|
|
691
|
-
var httpServer = (0,
|
|
750
|
+
var httpServer = (0, import_neko_helper3.createSingleton)(() => {
|
|
692
751
|
const server = new http_exports.HttpServer();
|
|
693
752
|
server.setErrorHandler(handleHttpErrors);
|
|
694
753
|
server.setRouter(router());
|
|
695
754
|
return server;
|
|
696
755
|
});
|
|
697
|
-
var logger = (
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
mailer_config.config
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
queue_config.
|
|
722
|
-
queue_config
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
});
|
|
756
|
+
var logger = wrapSingletonWithAccessors(
|
|
757
|
+
(0, import_neko_helper3.createSingleton)((label) => {
|
|
758
|
+
const logger_config = import_neko_config.config.get(["loggers", label].join("."));
|
|
759
|
+
const rc = new import_neko_logger.Logger(logger_config);
|
|
760
|
+
rc.setExtrasFunction((message) => {
|
|
761
|
+
message.requestId = (0, import_neko_context3.ctxSafe)()?.get("requestId") || "N/A";
|
|
762
|
+
return message;
|
|
763
|
+
});
|
|
764
|
+
return rc;
|
|
765
|
+
})
|
|
766
|
+
);
|
|
767
|
+
var mailer = wrapSingletonWithAccessors(
|
|
768
|
+
(0, import_neko_helper3.createSingleton)((label) => {
|
|
769
|
+
const mailer_config = import_neko_config.config.get(["mailer", label].join("."));
|
|
770
|
+
const provider = import_neko_mailer2.MailerProviderFactory.create(
|
|
771
|
+
mailer_config.provider,
|
|
772
|
+
mailer_config.config
|
|
773
|
+
);
|
|
774
|
+
const rc = new import_neko_mailer2.Mailer(provider);
|
|
775
|
+
return rc;
|
|
776
|
+
})
|
|
777
|
+
);
|
|
778
|
+
var queue = wrapSingletonWithAccessors(
|
|
779
|
+
(0, import_neko_helper3.createSingleton)((label) => {
|
|
780
|
+
const queue_config = import_neko_config.config.get(["queues", label].join("."));
|
|
781
|
+
if (!queue_config) {
|
|
782
|
+
throw new Error(`Queue configuration for '${label}' not found`);
|
|
783
|
+
}
|
|
784
|
+
const provider = import_neko_queue2.QueueTransportFactory.create(
|
|
785
|
+
queue_config.provider,
|
|
786
|
+
queue_config.config
|
|
787
|
+
);
|
|
788
|
+
return new import_neko_queue2.QueueConnection(provider);
|
|
789
|
+
})
|
|
790
|
+
);
|
|
791
|
+
var cache = wrapSingletonWithAccessors(
|
|
792
|
+
(0, import_neko_helper3.createSingleton)((label) => {
|
|
793
|
+
const cache_config = import_neko_config.config.get(["caches", label].join("."));
|
|
794
|
+
if (!cache_config) {
|
|
795
|
+
throw new Error(`Cache configuration for '${label}' not found`);
|
|
796
|
+
}
|
|
797
|
+
const provider = CacheProviderFactory.create(
|
|
798
|
+
cache_config.provider,
|
|
799
|
+
cache_config.config
|
|
800
|
+
);
|
|
801
|
+
return new import_neko_cache2.Cache(provider);
|
|
802
|
+
})
|
|
803
|
+
);
|
|
737
804
|
|
|
738
805
|
// src/app/console/generate/GenerateControllerCommand.mts
|
|
739
806
|
var import_clipanion2 = require("clipanion");
|