@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
|
@@ -79,6 +79,7 @@ var MiddlewareFactory = class {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
// ../neko-router/dist/CompiledRoute.mjs
|
|
82
|
+
var import_neko_helper = require("@devbro/neko-helper");
|
|
82
83
|
var CompiledRoute = class {
|
|
83
84
|
static {
|
|
84
85
|
__name(this, "CompiledRoute");
|
|
@@ -99,7 +100,7 @@ var CompiledRoute = class {
|
|
|
99
100
|
for (const middleware of [...this.globalMiddlewares, ...this.route.getMiddlewares()]) {
|
|
100
101
|
if (middleware instanceof Middleware) {
|
|
101
102
|
this.middlewares.push(middleware);
|
|
102
|
-
} else if (
|
|
103
|
+
} else if ((0, import_neko_helper.isClass)(middleware)) {
|
|
103
104
|
this.middlewares.push(middleware.getInstance({}));
|
|
104
105
|
} else if (typeof middleware === "function") {
|
|
105
106
|
this.middlewares.push(MiddlewareFactory.create(middleware));
|
|
@@ -108,9 +109,6 @@ var CompiledRoute = class {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
|
-
isClass(func) {
|
|
112
|
-
return typeof func === "function" && /^class\s/.test(Function.prototype.toString.call(func));
|
|
113
|
-
}
|
|
114
112
|
async run() {
|
|
115
113
|
return await this.runMiddlewares(this.middlewares, this.request, this.response);
|
|
116
114
|
}
|
|
@@ -246,7 +244,7 @@ var Route = class {
|
|
|
246
244
|
i = start;
|
|
247
245
|
} else if (char === "*") {
|
|
248
246
|
let start = i + 1;
|
|
249
|
-
while (start < path2.length && /[a-zA-Z0-9_
|
|
247
|
+
while (start < path2.length && /[a-zA-Z0-9_]/.test(path2[start])) {
|
|
250
248
|
start++;
|
|
251
249
|
}
|
|
252
250
|
tokens.push({ type: "WILDCARD", value: path2.slice(i + 1, start) });
|
|
@@ -457,7 +455,7 @@ var Router = class {
|
|
|
457
455
|
|
|
458
456
|
// src/facades.mts
|
|
459
457
|
var import_neko_scheduler = require("@devbro/neko-scheduler");
|
|
460
|
-
var
|
|
458
|
+
var import_neko_helper3 = require("@devbro/neko-helper");
|
|
461
459
|
var import_neko_context3 = require("@devbro/neko-context");
|
|
462
460
|
var import_neko_storage2 = require("@devbro/neko-storage");
|
|
463
461
|
var import_neko_mailer2 = require("@devbro/neko-mailer");
|
|
@@ -498,7 +496,7 @@ __export(queue_exports, {
|
|
|
498
496
|
DatabaseTransport: () => DatabaseTransport
|
|
499
497
|
});
|
|
500
498
|
__reExport(queue_exports, require("@devbro/neko-queue"));
|
|
501
|
-
var
|
|
499
|
+
var import_neko_helper2 = require("@devbro/neko-helper");
|
|
502
500
|
var import_neko_context2 = require("@devbro/neko-context");
|
|
503
501
|
var DatabaseTransport = class {
|
|
504
502
|
static {
|
|
@@ -559,7 +557,7 @@ var DatabaseTransport = class {
|
|
|
559
557
|
}, "processMessage");
|
|
560
558
|
constructor(config3 = {}) {
|
|
561
559
|
this.config = { ...this.config, ...config3 };
|
|
562
|
-
this.repeater = (0,
|
|
560
|
+
this.repeater = (0, import_neko_helper2.createRepeater)(
|
|
563
561
|
this.processMessage,
|
|
564
562
|
this.config.listen_interval * 1e3
|
|
565
563
|
);
|
|
@@ -627,6 +625,24 @@ import_neko_queue.QueueTransportFactory.register("database", (opt) => {
|
|
|
627
625
|
import_neko_queue.QueueTransportFactory.register("memory", (opt) => {
|
|
628
626
|
return new import_neko_queue.MemoryTransport(opt);
|
|
629
627
|
});
|
|
628
|
+
import_neko_queue.QueueTransportFactory.register("sqs", (opt) => {
|
|
629
|
+
return new import_neko_queue.AwsSqsTransport(opt);
|
|
630
|
+
});
|
|
631
|
+
import_neko_queue.QueueTransportFactory.register("amqp", (opt) => {
|
|
632
|
+
return new import_neko_queue.AmqpTransport(opt);
|
|
633
|
+
});
|
|
634
|
+
import_neko_queue.QueueTransportFactory.register("redis", (opt) => {
|
|
635
|
+
return new import_neko_queue.RedisTransport(opt);
|
|
636
|
+
});
|
|
637
|
+
import_neko_queue.QueueTransportFactory.register("async", (opt) => {
|
|
638
|
+
return new import_neko_queue.AsyncTransport();
|
|
639
|
+
});
|
|
640
|
+
import_neko_queue.QueueTransportFactory.register("azure_service_bus", (opt) => {
|
|
641
|
+
return new import_neko_queue.AzureServiceBusTransport(opt);
|
|
642
|
+
});
|
|
643
|
+
import_neko_queue.QueueTransportFactory.register("google_pubsub", (opt) => {
|
|
644
|
+
return new import_neko_queue.GooglePubSubTransport(opt);
|
|
645
|
+
});
|
|
630
646
|
var CacheProviderFactory = class _CacheProviderFactory {
|
|
631
647
|
static {
|
|
632
648
|
__name(this, "CacheProviderFactory");
|
|
@@ -657,32 +673,75 @@ import_neko_storage.StorageProviderFactory.register("local", (opt) => {
|
|
|
657
673
|
import_neko_storage.StorageProviderFactory.register("s3", (opt) => {
|
|
658
674
|
return new import_neko_storage.AWSS3StorageProvider(opt);
|
|
659
675
|
});
|
|
676
|
+
import_neko_storage.StorageProviderFactory.register("gcp", (opt) => {
|
|
677
|
+
return new import_neko_storage.GCPStorageProvider(opt);
|
|
678
|
+
});
|
|
679
|
+
import_neko_storage.StorageProviderFactory.register("azure", (opt) => {
|
|
680
|
+
return new import_neko_storage.AzureBlobStorageProvider(opt);
|
|
681
|
+
});
|
|
682
|
+
import_neko_storage.StorageProviderFactory.register("ftp", (opt) => {
|
|
683
|
+
return new import_neko_storage.FTPStorageProvider(opt);
|
|
684
|
+
});
|
|
685
|
+
import_neko_storage.StorageProviderFactory.register("sftp", (opt) => {
|
|
686
|
+
return new import_neko_storage.SFTPStorageProvider(opt);
|
|
687
|
+
});
|
|
660
688
|
|
|
661
689
|
// src/facades.mts
|
|
662
690
|
var import_neko_cache2 = require("@devbro/neko-cache");
|
|
663
691
|
var import_neko_queue2 = require("@devbro/neko-queue");
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
692
|
+
function wrapSingletonWithAccessors(singletonFn) {
|
|
693
|
+
let methodsInitialized = false;
|
|
694
|
+
const initializeMethods = /* @__PURE__ */ __name(() => {
|
|
695
|
+
if (methodsInitialized) return;
|
|
696
|
+
const defaultInstance = singletonFn();
|
|
697
|
+
const prototype = Object.getPrototypeOf(defaultInstance);
|
|
698
|
+
const methodNames = Object.getOwnPropertyNames(prototype).filter(
|
|
699
|
+
(name) => name !== "constructor" && typeof prototype[name] === "function"
|
|
700
|
+
);
|
|
701
|
+
for (const methodName of methodNames) {
|
|
702
|
+
singletonFn[methodName] = (...args) => {
|
|
703
|
+
const instance = singletonFn();
|
|
704
|
+
return instance[methodName](...args);
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
methodsInitialized = true;
|
|
708
|
+
}, "initializeMethods");
|
|
709
|
+
return new Proxy(singletonFn, {
|
|
710
|
+
get(target, prop, receiver) {
|
|
711
|
+
if (typeof prop === "string" && !Reflect.has(target, prop)) {
|
|
712
|
+
initializeMethods();
|
|
713
|
+
}
|
|
714
|
+
return Reflect.get(target, prop, receiver);
|
|
715
|
+
}
|
|
673
716
|
});
|
|
674
|
-
|
|
675
|
-
|
|
717
|
+
}
|
|
718
|
+
__name(wrapSingletonWithAccessors, "wrapSingletonWithAccessors");
|
|
719
|
+
var router = (0, import_neko_helper3.createSingleton)(() => new Router());
|
|
720
|
+
var scheduler = wrapSingletonWithAccessors(
|
|
721
|
+
(0, import_neko_helper3.createSingleton)(() => {
|
|
722
|
+
const rc = new import_neko_scheduler.Scheduler();
|
|
723
|
+
rc.setErrorHandler((err, job) => {
|
|
724
|
+
logger().error({
|
|
725
|
+
msg: "Scheduled job error",
|
|
726
|
+
err,
|
|
727
|
+
job_name: job.getName()
|
|
728
|
+
});
|
|
729
|
+
});
|
|
730
|
+
return rc;
|
|
731
|
+
})
|
|
732
|
+
);
|
|
676
733
|
var db = /* @__PURE__ */ __name((label = "default") => (0, import_neko_context3.ctx)().getOrThrow(["database", label]), "db");
|
|
677
|
-
var storage = (
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
734
|
+
var storage = wrapSingletonWithAccessors(
|
|
735
|
+
(0, import_neko_helper3.createSingleton)((label = "default") => {
|
|
736
|
+
let storage_config = import_neko_config.config.get(["storages", label].join("."));
|
|
737
|
+
const provider = import_neko_storage2.StorageProviderFactory.create(
|
|
738
|
+
storage_config.provider,
|
|
739
|
+
storage_config.config
|
|
740
|
+
);
|
|
741
|
+
return new import_neko_storage2.Storage(provider);
|
|
742
|
+
})
|
|
743
|
+
);
|
|
744
|
+
var cli = (0, import_neko_helper3.createSingleton)(() => {
|
|
686
745
|
const [node, app, ...args] = process.argv;
|
|
687
746
|
return new import_clipanion.Cli({
|
|
688
747
|
binaryLabel: `My Application`,
|
|
@@ -690,52 +749,60 @@ var cli = (0, import_neko_helper2.createSingleton)(() => {
|
|
|
690
749
|
binaryVersion: `1.0.0`
|
|
691
750
|
});
|
|
692
751
|
});
|
|
693
|
-
var httpServer = (0,
|
|
752
|
+
var httpServer = (0, import_neko_helper3.createSingleton)(() => {
|
|
694
753
|
const server = new http_exports.HttpServer();
|
|
695
754
|
server.setErrorHandler(handleHttpErrors);
|
|
696
755
|
server.setRouter(router());
|
|
697
756
|
return server;
|
|
698
757
|
});
|
|
699
|
-
var logger = (
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
mailer_config.config
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
queue_config.
|
|
724
|
-
queue_config
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
});
|
|
758
|
+
var logger = wrapSingletonWithAccessors(
|
|
759
|
+
(0, import_neko_helper3.createSingleton)((label) => {
|
|
760
|
+
const logger_config = import_neko_config.config.get(["loggers", label].join("."));
|
|
761
|
+
const rc = new import_neko_logger.Logger(logger_config);
|
|
762
|
+
rc.setExtrasFunction((message) => {
|
|
763
|
+
message.requestId = (0, import_neko_context3.ctxSafe)()?.get("requestId") || "N/A";
|
|
764
|
+
return message;
|
|
765
|
+
});
|
|
766
|
+
return rc;
|
|
767
|
+
})
|
|
768
|
+
);
|
|
769
|
+
var mailer = wrapSingletonWithAccessors(
|
|
770
|
+
(0, import_neko_helper3.createSingleton)((label) => {
|
|
771
|
+
const mailer_config = import_neko_config.config.get(["mailer", label].join("."));
|
|
772
|
+
const provider = import_neko_mailer2.MailerProviderFactory.create(
|
|
773
|
+
mailer_config.provider,
|
|
774
|
+
mailer_config.config
|
|
775
|
+
);
|
|
776
|
+
const rc = new import_neko_mailer2.Mailer(provider);
|
|
777
|
+
return rc;
|
|
778
|
+
})
|
|
779
|
+
);
|
|
780
|
+
var queue = wrapSingletonWithAccessors(
|
|
781
|
+
(0, import_neko_helper3.createSingleton)((label) => {
|
|
782
|
+
const queue_config = import_neko_config.config.get(["queues", label].join("."));
|
|
783
|
+
if (!queue_config) {
|
|
784
|
+
throw new Error(`Queue configuration for '${label}' not found`);
|
|
785
|
+
}
|
|
786
|
+
const provider = import_neko_queue2.QueueTransportFactory.create(
|
|
787
|
+
queue_config.provider,
|
|
788
|
+
queue_config.config
|
|
789
|
+
);
|
|
790
|
+
return new import_neko_queue2.QueueConnection(provider);
|
|
791
|
+
})
|
|
792
|
+
);
|
|
793
|
+
var cache = wrapSingletonWithAccessors(
|
|
794
|
+
(0, import_neko_helper3.createSingleton)((label) => {
|
|
795
|
+
const cache_config = import_neko_config.config.get(["caches", label].join("."));
|
|
796
|
+
if (!cache_config) {
|
|
797
|
+
throw new Error(`Cache configuration for '${label}' not found`);
|
|
798
|
+
}
|
|
799
|
+
const provider = CacheProviderFactory.create(
|
|
800
|
+
cache_config.provider,
|
|
801
|
+
cache_config.config
|
|
802
|
+
);
|
|
803
|
+
return new import_neko_cache2.Cache(provider);
|
|
804
|
+
})
|
|
805
|
+
);
|
|
739
806
|
|
|
740
807
|
// src/app/console/StartCommand.mts
|
|
741
808
|
var import_neko_sql = require("@devbro/neko-sql");
|
|
@@ -744,12 +811,15 @@ var StartCommand = class extends import_clipanion2.Command {
|
|
|
744
811
|
__name(this, "StartCommand");
|
|
745
812
|
}
|
|
746
813
|
scheduler = import_clipanion2.Option.Boolean(`--scheduler`, false);
|
|
814
|
+
cron = import_clipanion2.Option.Boolean(`--cron`, false);
|
|
747
815
|
http = import_clipanion2.Option.Boolean(`--http`, false);
|
|
748
816
|
queue = import_clipanion2.Option.Boolean(`--queue`, false);
|
|
749
817
|
all = import_clipanion2.Option.Boolean("--all", false);
|
|
750
818
|
static paths = [[`start`]];
|
|
751
819
|
async execute() {
|
|
752
|
-
if ([this.all, this.http, this.scheduler, this.queue].filter(
|
|
820
|
+
if ([this.all, this.http, this.scheduler || this.cron, this.queue].filter(
|
|
821
|
+
(x) => x
|
|
822
|
+
).length == 0) {
|
|
753
823
|
this.context.stdout.write(
|
|
754
824
|
`No service was selected. please check -h for details
|
|
755
825
|
`
|
|
@@ -759,7 +829,7 @@ var StartCommand = class extends import_clipanion2.Command {
|
|
|
759
829
|
logger().info(`Starting Server
|
|
760
830
|
`);
|
|
761
831
|
import_neko_sql.PostgresqlConnection.defaults.idleTimeoutMillis = 1e4;
|
|
762
|
-
if (this.scheduler || this.all) {
|
|
832
|
+
if (this.scheduler || this.cron || this.all) {
|
|
763
833
|
logger().info(`starting scheduler
|
|
764
834
|
`);
|
|
765
835
|
scheduler().start();
|