@devbro/pashmak 0.1.56 → 0.1.58
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/cjs/app/console/DefaultCommand.js +52 -0
- package/dist/cjs/app/console/KeyGenerateCommand.js +52 -0
- package/dist/cjs/app/console/StartCommand.js +52 -0
- package/dist/cjs/app/console/generate/GenerateApiDocsCommand.js +52 -0
- package/dist/cjs/app/console/generate/GenerateControllerCommand.js +52 -0
- package/dist/cjs/app/console/generate/index.js +52 -0
- package/dist/cjs/app/console/index.js +265 -7
- package/dist/cjs/app/console/migrate/GenerateMigrateCommand.js +52 -0
- package/dist/cjs/app/console/migrate/MigrateCommand.js +52 -0
- package/dist/cjs/app/console/migrate/MigrateRollbackCommand.js +52 -0
- package/dist/cjs/app/console/migrate/index.js +52 -0
- package/dist/cjs/app/console/project/CreateProjectCommand.js +213 -7
- package/dist/cjs/app/console/queue/GenerateQueueMigrateCommand.js +52 -0
- package/dist/cjs/bin/pashmak_cli.js +213 -7
- package/dist/cjs/cache/MultiCache.js +71 -0
- package/dist/cjs/{cache.js → cache/cache.js} +54 -2
- package/dist/cjs/facades.js +52 -0
- package/dist/cjs/factories.js +52 -0
- package/dist/cjs/http.js +52 -0
- package/dist/cjs/index.js +265 -7
- package/dist/cjs/middlewares.js +52 -0
- package/dist/cjs/queue.js +52 -0
- package/dist/esm/app/console/project/CreateProjectCommand.d.mts +7 -2
- package/dist/esm/app/console/project/CreateProjectCommand.mjs +214 -8
- package/dist/esm/app/console/project/CreateProjectCommand.mjs.map +1 -1
- package/dist/esm/cache/MultiCache.d.mts +14 -0
- package/dist/esm/cache/MultiCache.mjs +47 -0
- package/dist/esm/cache/MultiCache.mjs.map +1 -0
- package/dist/esm/{cache.mjs → cache/cache.mjs} +1 -1
- package/dist/esm/cache/cache.mjs.map +1 -0
- package/dist/esm/factories.mjs +9 -0
- package/dist/esm/factories.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/esm/cache.mjs.map +0 -1
- /package/dist/esm/{cache.d.mts → cache/cache.d.mts} +0 -0
|
@@ -29,7 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
));
|
|
30
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
31
|
|
|
32
|
-
// src/cache.mts
|
|
32
|
+
// src/cache/cache.mts
|
|
33
33
|
var cache_exports = {};
|
|
34
34
|
__export(cache_exports, {
|
|
35
35
|
cacheQuery: () => cacheQuery
|
|
@@ -593,6 +593,51 @@ var DatabaseTransport = class {
|
|
|
593
593
|
// src/factories.mts
|
|
594
594
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
595
595
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
596
|
+
|
|
597
|
+
// src/cache/MultiCache.mts
|
|
598
|
+
var MultiCache = class {
|
|
599
|
+
constructor(caches) {
|
|
600
|
+
this.caches = caches;
|
|
601
|
+
}
|
|
602
|
+
static {
|
|
603
|
+
__name(this, "MultiCache");
|
|
604
|
+
}
|
|
605
|
+
async get(key) {
|
|
606
|
+
for (const cache2 of this.caches) {
|
|
607
|
+
const value = await cache2.get(key);
|
|
608
|
+
if (value !== void 0) {
|
|
609
|
+
return value;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return void 0;
|
|
613
|
+
}
|
|
614
|
+
async put(key, value, ttl) {
|
|
615
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
616
|
+
}
|
|
617
|
+
async delete(key) {
|
|
618
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
619
|
+
}
|
|
620
|
+
async has(key) {
|
|
621
|
+
for (const cache2 of this.caches) {
|
|
622
|
+
if (await cache2.has(key)) {
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return false;
|
|
627
|
+
}
|
|
628
|
+
async increment(key, amount) {
|
|
629
|
+
let rc = void 0;
|
|
630
|
+
for (const cache2 of this.caches) {
|
|
631
|
+
let rc2 = await cache2.increment(key, amount);
|
|
632
|
+
if (rc === void 0) {
|
|
633
|
+
rc = rc2;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
return rc;
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
// src/factories.mts
|
|
596
641
|
var FlexibleFactory = class {
|
|
597
642
|
static {
|
|
598
643
|
__name(this, "FlexibleFactory");
|
|
@@ -663,6 +708,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
663
708
|
CacheProviderFactory.register("file", (opt) => {
|
|
664
709
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
665
710
|
});
|
|
711
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
712
|
+
const caches = [];
|
|
713
|
+
for (const c of opt.caches) {
|
|
714
|
+
caches.push(cache(c));
|
|
715
|
+
}
|
|
716
|
+
return new MultiCache(caches);
|
|
717
|
+
});
|
|
666
718
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
667
719
|
return new import_neko_cache.DisabledCacheProvider();
|
|
668
720
|
});
|
|
@@ -803,7 +855,7 @@ var cache = wrapSingletonWithAccessors(
|
|
|
803
855
|
})
|
|
804
856
|
);
|
|
805
857
|
|
|
806
|
-
// src/cache.mts
|
|
858
|
+
// src/cache/cache.mts
|
|
807
859
|
async function cacheQuery(q, options = {}) {
|
|
808
860
|
options.ttl = options.ttl ?? 3600;
|
|
809
861
|
options.cache_label = options.cache_label ?? "default";
|
package/dist/cjs/facades.js
CHANGED
|
@@ -601,6 +601,51 @@ var DatabaseTransport = class {
|
|
|
601
601
|
// src/factories.mts
|
|
602
602
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
603
603
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
604
|
+
|
|
605
|
+
// src/cache/MultiCache.mts
|
|
606
|
+
var MultiCache = class {
|
|
607
|
+
constructor(caches) {
|
|
608
|
+
this.caches = caches;
|
|
609
|
+
}
|
|
610
|
+
static {
|
|
611
|
+
__name(this, "MultiCache");
|
|
612
|
+
}
|
|
613
|
+
async get(key) {
|
|
614
|
+
for (const cache2 of this.caches) {
|
|
615
|
+
const value = await cache2.get(key);
|
|
616
|
+
if (value !== void 0) {
|
|
617
|
+
return value;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return void 0;
|
|
621
|
+
}
|
|
622
|
+
async put(key, value, ttl) {
|
|
623
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
624
|
+
}
|
|
625
|
+
async delete(key) {
|
|
626
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
627
|
+
}
|
|
628
|
+
async has(key) {
|
|
629
|
+
for (const cache2 of this.caches) {
|
|
630
|
+
if (await cache2.has(key)) {
|
|
631
|
+
return true;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
async increment(key, amount) {
|
|
637
|
+
let rc = void 0;
|
|
638
|
+
for (const cache2 of this.caches) {
|
|
639
|
+
let rc2 = await cache2.increment(key, amount);
|
|
640
|
+
if (rc === void 0) {
|
|
641
|
+
rc = rc2;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return rc;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
// src/factories.mts
|
|
604
649
|
var FlexibleFactory = class {
|
|
605
650
|
static {
|
|
606
651
|
__name(this, "FlexibleFactory");
|
|
@@ -671,6 +716,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
671
716
|
CacheProviderFactory.register("file", (opt) => {
|
|
672
717
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
673
718
|
});
|
|
719
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
720
|
+
const caches = [];
|
|
721
|
+
for (const c of opt.caches) {
|
|
722
|
+
caches.push(cache(c));
|
|
723
|
+
}
|
|
724
|
+
return new MultiCache(caches);
|
|
725
|
+
});
|
|
674
726
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
675
727
|
return new import_neko_cache.DisabledCacheProvider();
|
|
676
728
|
});
|
package/dist/cjs/factories.js
CHANGED
|
@@ -709,6 +709,51 @@ var DatabaseTransport = class {
|
|
|
709
709
|
// src/factories.mts
|
|
710
710
|
var import_neko_cache2 = require("@devbro/neko-cache");
|
|
711
711
|
var import_neko_storage2 = require("@devbro/neko-storage");
|
|
712
|
+
|
|
713
|
+
// src/cache/MultiCache.mts
|
|
714
|
+
var MultiCache = class {
|
|
715
|
+
constructor(caches) {
|
|
716
|
+
this.caches = caches;
|
|
717
|
+
}
|
|
718
|
+
static {
|
|
719
|
+
__name(this, "MultiCache");
|
|
720
|
+
}
|
|
721
|
+
async get(key) {
|
|
722
|
+
for (const cache2 of this.caches) {
|
|
723
|
+
const value = await cache2.get(key);
|
|
724
|
+
if (value !== void 0) {
|
|
725
|
+
return value;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return void 0;
|
|
729
|
+
}
|
|
730
|
+
async put(key, value, ttl) {
|
|
731
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
732
|
+
}
|
|
733
|
+
async delete(key) {
|
|
734
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
735
|
+
}
|
|
736
|
+
async has(key) {
|
|
737
|
+
for (const cache2 of this.caches) {
|
|
738
|
+
if (await cache2.has(key)) {
|
|
739
|
+
return true;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
async increment(key, amount) {
|
|
745
|
+
let rc = void 0;
|
|
746
|
+
for (const cache2 of this.caches) {
|
|
747
|
+
let rc2 = await cache2.increment(key, amount);
|
|
748
|
+
if (rc === void 0) {
|
|
749
|
+
rc = rc2;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return rc;
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
// src/factories.mts
|
|
712
757
|
var FlexibleFactory = class {
|
|
713
758
|
static {
|
|
714
759
|
__name(this, "FlexibleFactory");
|
|
@@ -779,6 +824,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
779
824
|
CacheProviderFactory.register("file", (opt) => {
|
|
780
825
|
return new import_neko_cache2.FileCacheProvider(opt);
|
|
781
826
|
});
|
|
827
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
828
|
+
const caches = [];
|
|
829
|
+
for (const c of opt.caches) {
|
|
830
|
+
caches.push(cache(c));
|
|
831
|
+
}
|
|
832
|
+
return new MultiCache(caches);
|
|
833
|
+
});
|
|
782
834
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
783
835
|
return new import_neko_cache2.DisabledCacheProvider();
|
|
784
836
|
});
|
package/dist/cjs/http.js
CHANGED
|
@@ -570,6 +570,51 @@ var DatabaseTransport = class {
|
|
|
570
570
|
// src/factories.mts
|
|
571
571
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
572
572
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
573
|
+
|
|
574
|
+
// src/cache/MultiCache.mts
|
|
575
|
+
var MultiCache = class {
|
|
576
|
+
constructor(caches) {
|
|
577
|
+
this.caches = caches;
|
|
578
|
+
}
|
|
579
|
+
static {
|
|
580
|
+
__name(this, "MultiCache");
|
|
581
|
+
}
|
|
582
|
+
async get(key) {
|
|
583
|
+
for (const cache2 of this.caches) {
|
|
584
|
+
const value = await cache2.get(key);
|
|
585
|
+
if (value !== void 0) {
|
|
586
|
+
return value;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return void 0;
|
|
590
|
+
}
|
|
591
|
+
async put(key, value, ttl) {
|
|
592
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
593
|
+
}
|
|
594
|
+
async delete(key) {
|
|
595
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
596
|
+
}
|
|
597
|
+
async has(key) {
|
|
598
|
+
for (const cache2 of this.caches) {
|
|
599
|
+
if (await cache2.has(key)) {
|
|
600
|
+
return true;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return false;
|
|
604
|
+
}
|
|
605
|
+
async increment(key, amount) {
|
|
606
|
+
let rc = void 0;
|
|
607
|
+
for (const cache2 of this.caches) {
|
|
608
|
+
let rc2 = await cache2.increment(key, amount);
|
|
609
|
+
if (rc === void 0) {
|
|
610
|
+
rc = rc2;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
return rc;
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
// src/factories.mts
|
|
573
618
|
var FlexibleFactory = class {
|
|
574
619
|
static {
|
|
575
620
|
__name(this, "FlexibleFactory");
|
|
@@ -640,6 +685,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
640
685
|
CacheProviderFactory.register("file", (opt) => {
|
|
641
686
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
642
687
|
});
|
|
688
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
689
|
+
const caches = [];
|
|
690
|
+
for (const c of opt.caches) {
|
|
691
|
+
caches.push(cache(c));
|
|
692
|
+
}
|
|
693
|
+
return new MultiCache(caches);
|
|
694
|
+
});
|
|
643
695
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
644
696
|
return new import_neko_cache.DisabledCacheProvider();
|
|
645
697
|
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -1739,6 +1739,51 @@ var DatabaseTransport = class {
|
|
|
1739
1739
|
// src/factories.mts
|
|
1740
1740
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
1741
1741
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
1742
|
+
|
|
1743
|
+
// src/cache/MultiCache.mts
|
|
1744
|
+
var MultiCache = class {
|
|
1745
|
+
constructor(caches) {
|
|
1746
|
+
this.caches = caches;
|
|
1747
|
+
}
|
|
1748
|
+
static {
|
|
1749
|
+
__name(this, "MultiCache");
|
|
1750
|
+
}
|
|
1751
|
+
async get(key) {
|
|
1752
|
+
for (const cache2 of this.caches) {
|
|
1753
|
+
const value = await cache2.get(key);
|
|
1754
|
+
if (value !== void 0) {
|
|
1755
|
+
return value;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
return void 0;
|
|
1759
|
+
}
|
|
1760
|
+
async put(key, value, ttl) {
|
|
1761
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
1762
|
+
}
|
|
1763
|
+
async delete(key) {
|
|
1764
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
1765
|
+
}
|
|
1766
|
+
async has(key) {
|
|
1767
|
+
for (const cache2 of this.caches) {
|
|
1768
|
+
if (await cache2.has(key)) {
|
|
1769
|
+
return true;
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
return false;
|
|
1773
|
+
}
|
|
1774
|
+
async increment(key, amount) {
|
|
1775
|
+
let rc = void 0;
|
|
1776
|
+
for (const cache2 of this.caches) {
|
|
1777
|
+
let rc2 = await cache2.increment(key, amount);
|
|
1778
|
+
if (rc === void 0) {
|
|
1779
|
+
rc = rc2;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
return rc;
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
|
|
1786
|
+
// src/factories.mts
|
|
1742
1787
|
var FlexibleFactory = class {
|
|
1743
1788
|
static {
|
|
1744
1789
|
__name(this, "FlexibleFactory");
|
|
@@ -1809,6 +1854,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
1809
1854
|
CacheProviderFactory.register("file", (opt) => {
|
|
1810
1855
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
1811
1856
|
});
|
|
1857
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
1858
|
+
const caches = [];
|
|
1859
|
+
for (const c of opt.caches) {
|
|
1860
|
+
caches.push(cache(c));
|
|
1861
|
+
}
|
|
1862
|
+
return new MultiCache(caches);
|
|
1863
|
+
});
|
|
1812
1864
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
1813
1865
|
return new import_neko_cache.DisabledCacheProvider();
|
|
1814
1866
|
});
|
|
@@ -2648,8 +2700,34 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2648
2700
|
executor = "";
|
|
2649
2701
|
packageManager = "";
|
|
2650
2702
|
linter = "";
|
|
2651
|
-
validation_library = ""
|
|
2652
|
-
|
|
2703
|
+
validation_library = import_clipanion10.Option.String("--validation-library", {
|
|
2704
|
+
description: "Validation library to use (yup, zod, none)",
|
|
2705
|
+
required: false
|
|
2706
|
+
});
|
|
2707
|
+
database_type = import_clipanion10.Option.String("--database-type", {
|
|
2708
|
+
description: "Database type to use (postgresql, mysql, sqlite)",
|
|
2709
|
+
required: false
|
|
2710
|
+
});
|
|
2711
|
+
cache_library = import_clipanion10.Option.String("--cache-library", {
|
|
2712
|
+
description: "Cache library to use (redis, memcached, none)",
|
|
2713
|
+
required: false
|
|
2714
|
+
});
|
|
2715
|
+
mailer_library = import_clipanion10.Option.String("--mailer-library", {
|
|
2716
|
+
description: "Mailer library to use (@aws-sdk/client-ses, nodemailer, none)",
|
|
2717
|
+
required: false
|
|
2718
|
+
});
|
|
2719
|
+
queue_library = import_clipanion10.Option.String("--queue-library", {
|
|
2720
|
+
description: "Queue library to use (@aws-sdk/client-sqs, @azure/service-bus, @google-cloud/pubsub, amqplib, redis, none)",
|
|
2721
|
+
required: false
|
|
2722
|
+
});
|
|
2723
|
+
storage_library = import_clipanion10.Option.String("--storage-library", {
|
|
2724
|
+
description: "Storage library to use (@aws-sdk/client-s3, @azure/storage-blob, @google-cloud/storage, basic-ftp, ssh2-sftp-client, none)",
|
|
2725
|
+
required: false
|
|
2726
|
+
});
|
|
2727
|
+
initGit = import_clipanion10.Option.Boolean("--git", {
|
|
2728
|
+
description: "Initialize a git repository (use --no-git to skip)",
|
|
2729
|
+
required: false
|
|
2730
|
+
});
|
|
2653
2731
|
async folderExists(folderPath) {
|
|
2654
2732
|
try {
|
|
2655
2733
|
const stats = await fs7.stat(folderPath);
|
|
@@ -2803,7 +2881,7 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2803
2881
|
await fs7.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
2804
2882
|
}
|
|
2805
2883
|
async setupGeneralPackages() {
|
|
2806
|
-
this.validation_library = await (0, import_prompts.select)({
|
|
2884
|
+
this.validation_library = this.validation_library ?? await (0, import_prompts.select)({
|
|
2807
2885
|
message: "Select a package you want for validation",
|
|
2808
2886
|
choices: [
|
|
2809
2887
|
{
|
|
@@ -2824,8 +2902,15 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2824
2902
|
}
|
|
2825
2903
|
]
|
|
2826
2904
|
});
|
|
2827
|
-
this.validation_library === "
|
|
2828
|
-
|
|
2905
|
+
if (this.validation_library === "yup" || this.validation_library === "zod") {
|
|
2906
|
+
await this.addPackage(this.validation_library);
|
|
2907
|
+
} else if (this.validation_library === "none") {
|
|
2908
|
+
} else {
|
|
2909
|
+
throw new Error(
|
|
2910
|
+
"unexpected validation library: " + this.validation_library + ". Valid options are: yup, zod, none"
|
|
2911
|
+
);
|
|
2912
|
+
}
|
|
2913
|
+
this.database_type = this.database_type ?? await (0, import_prompts.select)({
|
|
2829
2914
|
message: "Select a database type (you can add more databases later)",
|
|
2830
2915
|
choices: [
|
|
2831
2916
|
{
|
|
@@ -2851,6 +2936,179 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2851
2936
|
await this.addPackage("mysql2");
|
|
2852
2937
|
} else if (this.database_type === "sqlite") {
|
|
2853
2938
|
await this.addPackage("sqlite3");
|
|
2939
|
+
} else {
|
|
2940
|
+
throw new Error(
|
|
2941
|
+
"unexpected database type: " + this.database_type + ". Valid options are: postgresql, mysql, sqlite"
|
|
2942
|
+
);
|
|
2943
|
+
}
|
|
2944
|
+
this.cache_library = this.cache_library ?? await (0, import_prompts.select)({
|
|
2945
|
+
message: "Select a cache library",
|
|
2946
|
+
choices: [
|
|
2947
|
+
{
|
|
2948
|
+
name: "Redis",
|
|
2949
|
+
value: "redis",
|
|
2950
|
+
description: "Redis client for Node.js"
|
|
2951
|
+
},
|
|
2952
|
+
{
|
|
2953
|
+
name: "Memcached",
|
|
2954
|
+
value: "memcached",
|
|
2955
|
+
description: "Memcached client for Node.js"
|
|
2956
|
+
},
|
|
2957
|
+
new import_prompts.Separator(),
|
|
2958
|
+
{
|
|
2959
|
+
name: "None",
|
|
2960
|
+
value: "none",
|
|
2961
|
+
disabled: false
|
|
2962
|
+
}
|
|
2963
|
+
]
|
|
2964
|
+
});
|
|
2965
|
+
if (this.cache_library === "redis") {
|
|
2966
|
+
await this.addPackage("redis");
|
|
2967
|
+
} else if (this.cache_library === "memcached") {
|
|
2968
|
+
await this.addPackage("memcached");
|
|
2969
|
+
} else if (this.cache_library === "none") {
|
|
2970
|
+
} else {
|
|
2971
|
+
throw new Error(
|
|
2972
|
+
"unexpected cache library: " + this.cache_library + ". Valid options are: redis, memcached, none"
|
|
2973
|
+
);
|
|
2974
|
+
}
|
|
2975
|
+
this.mailer_library = this.mailer_library ?? await (0, import_prompts.select)({
|
|
2976
|
+
message: "Select a mailer library",
|
|
2977
|
+
choices: [
|
|
2978
|
+
{
|
|
2979
|
+
name: "AWS SES",
|
|
2980
|
+
value: "@aws-sdk/client-ses",
|
|
2981
|
+
description: "AWS SDK for JavaScript v3 - SES client"
|
|
2982
|
+
},
|
|
2983
|
+
{
|
|
2984
|
+
name: "Nodemailer",
|
|
2985
|
+
value: "nodemailer",
|
|
2986
|
+
description: "Send emails with Node.js"
|
|
2987
|
+
},
|
|
2988
|
+
new import_prompts.Separator(),
|
|
2989
|
+
{
|
|
2990
|
+
name: "None",
|
|
2991
|
+
value: "none",
|
|
2992
|
+
disabled: false
|
|
2993
|
+
}
|
|
2994
|
+
]
|
|
2995
|
+
});
|
|
2996
|
+
if (this.mailer_library === "@aws-sdk/client-ses") {
|
|
2997
|
+
await this.addPackage("@aws-sdk/client-ses");
|
|
2998
|
+
} else if (this.mailer_library === "nodemailer") {
|
|
2999
|
+
await this.addPackage("nodemailer");
|
|
3000
|
+
await this.addPackage("@types/nodemailer", true);
|
|
3001
|
+
} else if (this.mailer_library === "none") {
|
|
3002
|
+
} else {
|
|
3003
|
+
throw new Error(
|
|
3004
|
+
"unexpected mailer library: " + this.mailer_library + ". Valid options are: @aws-sdk/client-ses, nodemailer, none"
|
|
3005
|
+
);
|
|
3006
|
+
}
|
|
3007
|
+
this.queue_library = this.queue_library ?? await (0, import_prompts.select)({
|
|
3008
|
+
message: "Select a queue library",
|
|
3009
|
+
choices: [
|
|
3010
|
+
{
|
|
3011
|
+
name: "AWS SQS",
|
|
3012
|
+
value: "@aws-sdk/client-sqs",
|
|
3013
|
+
description: "AWS SDK for JavaScript v3 - SQS client"
|
|
3014
|
+
},
|
|
3015
|
+
{
|
|
3016
|
+
name: "Azure Service Bus",
|
|
3017
|
+
value: "@azure/service-bus",
|
|
3018
|
+
description: "Azure Service Bus client for Node.js"
|
|
3019
|
+
},
|
|
3020
|
+
{
|
|
3021
|
+
name: "Google Cloud Pub/Sub",
|
|
3022
|
+
value: "@google-cloud/pubsub",
|
|
3023
|
+
description: "Google Cloud Pub/Sub client for Node.js"
|
|
3024
|
+
},
|
|
3025
|
+
{
|
|
3026
|
+
name: "RabbitMQ (amqplib)",
|
|
3027
|
+
value: "amqplib",
|
|
3028
|
+
description: "AMQP 0-9-1 client for Node.js"
|
|
3029
|
+
},
|
|
3030
|
+
{
|
|
3031
|
+
name: "Redis",
|
|
3032
|
+
value: "redis",
|
|
3033
|
+
description: "Redis client for Node.js"
|
|
3034
|
+
},
|
|
3035
|
+
new import_prompts.Separator(),
|
|
3036
|
+
{
|
|
3037
|
+
name: "None",
|
|
3038
|
+
value: "none",
|
|
3039
|
+
disabled: false
|
|
3040
|
+
}
|
|
3041
|
+
]
|
|
3042
|
+
});
|
|
3043
|
+
if (this.queue_library === "@aws-sdk/client-sqs") {
|
|
3044
|
+
await this.addPackage("@aws-sdk/client-sqs");
|
|
3045
|
+
} else if (this.queue_library === "@azure/service-bus") {
|
|
3046
|
+
await this.addPackage("@azure/service-bus");
|
|
3047
|
+
} else if (this.queue_library === "@google-cloud/pubsub") {
|
|
3048
|
+
await this.addPackage("@google-cloud/pubsub");
|
|
3049
|
+
} else if (this.queue_library === "amqplib") {
|
|
3050
|
+
await this.addPackage("amqplib");
|
|
3051
|
+
await this.addPackage("@types/amqplib", true);
|
|
3052
|
+
} else if (this.queue_library === "redis") {
|
|
3053
|
+
await this.addPackage("redis");
|
|
3054
|
+
} else if (this.queue_library === "none") {
|
|
3055
|
+
} else {
|
|
3056
|
+
throw new Error(
|
|
3057
|
+
"unexpected queue library: " + this.queue_library + ". Valid options are: @aws-sdk/client-sqs, @azure/service-bus, @google-cloud/pubsub, amqplib, redis, none"
|
|
3058
|
+
);
|
|
3059
|
+
}
|
|
3060
|
+
this.storage_library = this.storage_library ?? await (0, import_prompts.select)({
|
|
3061
|
+
message: "Select a storage library",
|
|
3062
|
+
choices: [
|
|
3063
|
+
{
|
|
3064
|
+
name: "@aws-sdk/client-s3",
|
|
3065
|
+
value: "@aws-sdk/client-s3",
|
|
3066
|
+
description: "AWS SDK for JavaScript v3 - S3 client"
|
|
3067
|
+
},
|
|
3068
|
+
{
|
|
3069
|
+
name: "@azure/storage-blob",
|
|
3070
|
+
value: "@azure/storage-blob",
|
|
3071
|
+
description: "Azure Storage Blob client for Node.js"
|
|
3072
|
+
},
|
|
3073
|
+
{
|
|
3074
|
+
name: "@google-cloud/storage",
|
|
3075
|
+
value: "@google-cloud/storage",
|
|
3076
|
+
description: "Google Cloud Storage client for Node.js"
|
|
3077
|
+
},
|
|
3078
|
+
{
|
|
3079
|
+
name: "basic-ftp",
|
|
3080
|
+
value: "basic-ftp",
|
|
3081
|
+
description: "FTP client for Node.js"
|
|
3082
|
+
},
|
|
3083
|
+
{
|
|
3084
|
+
name: "ssh2-sftp-client",
|
|
3085
|
+
value: "ssh2-sftp-client",
|
|
3086
|
+
description: "SFTP client for Node.js"
|
|
3087
|
+
},
|
|
3088
|
+
new import_prompts.Separator(),
|
|
3089
|
+
{
|
|
3090
|
+
name: "None",
|
|
3091
|
+
value: "none",
|
|
3092
|
+
disabled: false
|
|
3093
|
+
}
|
|
3094
|
+
]
|
|
3095
|
+
});
|
|
3096
|
+
if (this.storage_library === "@aws-sdk/client-s3") {
|
|
3097
|
+
await this.addPackage("@aws-sdk/client-s3");
|
|
3098
|
+
} else if (this.storage_library === "@azure/storage-blob") {
|
|
3099
|
+
await this.addPackage("@azure/storage-blob");
|
|
3100
|
+
} else if (this.storage_library === "@google-cloud/storage") {
|
|
3101
|
+
await this.addPackage("@google-cloud/storage");
|
|
3102
|
+
} else if (this.storage_library === "basic-ftp") {
|
|
3103
|
+
await this.addPackage("basic-ftp");
|
|
3104
|
+
} else if (this.storage_library === "ssh2-sftp-client") {
|
|
3105
|
+
await this.addPackage("ssh2-sftp-client");
|
|
3106
|
+
await this.addPackage("@types/ssh2-sftp-client", true);
|
|
3107
|
+
} else if (this.storage_library === "none") {
|
|
3108
|
+
} else {
|
|
3109
|
+
throw new Error(
|
|
3110
|
+
"unexpected storage library: " + this.storage_library + " . Valid options are: @aws-sdk/client-s3, @azure/storage-blob, @google-cloud/storage, basic-ftp, ssh2-sftp-client, none"
|
|
3111
|
+
);
|
|
2854
3112
|
}
|
|
2855
3113
|
await this.addPackage("@devbro/pashmak tsconfig-paths dotenv ");
|
|
2856
3114
|
await this.addPackage(
|
|
@@ -2907,7 +3165,7 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2907
3165
|
});
|
|
2908
3166
|
}
|
|
2909
3167
|
async setupGit() {
|
|
2910
|
-
|
|
3168
|
+
this.initGit = this.initGit ?? await (0, import_prompts.select)({
|
|
2911
3169
|
message: "Initialize a git repository?",
|
|
2912
3170
|
choices: [
|
|
2913
3171
|
{
|
|
@@ -2922,7 +3180,7 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2922
3180
|
}
|
|
2923
3181
|
]
|
|
2924
3182
|
});
|
|
2925
|
-
if (initGit) {
|
|
3183
|
+
if (this.initGit) {
|
|
2926
3184
|
const gitignoreContent = [
|
|
2927
3185
|
"node_modules/",
|
|
2928
3186
|
"dist/",
|
package/dist/cjs/middlewares.js
CHANGED
|
@@ -595,6 +595,51 @@ var DatabaseTransport = class {
|
|
|
595
595
|
// src/factories.mts
|
|
596
596
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
597
597
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
598
|
+
|
|
599
|
+
// src/cache/MultiCache.mts
|
|
600
|
+
var MultiCache = class {
|
|
601
|
+
constructor(caches) {
|
|
602
|
+
this.caches = caches;
|
|
603
|
+
}
|
|
604
|
+
static {
|
|
605
|
+
__name(this, "MultiCache");
|
|
606
|
+
}
|
|
607
|
+
async get(key) {
|
|
608
|
+
for (const cache2 of this.caches) {
|
|
609
|
+
const value = await cache2.get(key);
|
|
610
|
+
if (value !== void 0) {
|
|
611
|
+
return value;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return void 0;
|
|
615
|
+
}
|
|
616
|
+
async put(key, value, ttl) {
|
|
617
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
618
|
+
}
|
|
619
|
+
async delete(key) {
|
|
620
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
621
|
+
}
|
|
622
|
+
async has(key) {
|
|
623
|
+
for (const cache2 of this.caches) {
|
|
624
|
+
if (await cache2.has(key)) {
|
|
625
|
+
return true;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
async increment(key, amount) {
|
|
631
|
+
let rc = void 0;
|
|
632
|
+
for (const cache2 of this.caches) {
|
|
633
|
+
let rc2 = await cache2.increment(key, amount);
|
|
634
|
+
if (rc === void 0) {
|
|
635
|
+
rc = rc2;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return rc;
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
// src/factories.mts
|
|
598
643
|
var FlexibleFactory = class {
|
|
599
644
|
static {
|
|
600
645
|
__name(this, "FlexibleFactory");
|
|
@@ -665,6 +710,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
665
710
|
CacheProviderFactory.register("file", (opt) => {
|
|
666
711
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
667
712
|
});
|
|
713
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
714
|
+
const caches = [];
|
|
715
|
+
for (const c of opt.caches) {
|
|
716
|
+
caches.push(cache(c));
|
|
717
|
+
}
|
|
718
|
+
return new MultiCache(caches);
|
|
719
|
+
});
|
|
668
720
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
669
721
|
return new import_neko_cache.DisabledCacheProvider();
|
|
670
722
|
});
|