@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
|
@@ -1756,6 +1756,51 @@ var DatabaseTransport = class {
|
|
|
1756
1756
|
// src/factories.mts
|
|
1757
1757
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
1758
1758
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
1759
|
+
|
|
1760
|
+
// src/cache/MultiCache.mts
|
|
1761
|
+
var MultiCache = class {
|
|
1762
|
+
constructor(caches) {
|
|
1763
|
+
this.caches = caches;
|
|
1764
|
+
}
|
|
1765
|
+
static {
|
|
1766
|
+
__name(this, "MultiCache");
|
|
1767
|
+
}
|
|
1768
|
+
async get(key) {
|
|
1769
|
+
for (const cache2 of this.caches) {
|
|
1770
|
+
const value = await cache2.get(key);
|
|
1771
|
+
if (value !== void 0) {
|
|
1772
|
+
return value;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
return void 0;
|
|
1776
|
+
}
|
|
1777
|
+
async put(key, value, ttl) {
|
|
1778
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
1779
|
+
}
|
|
1780
|
+
async delete(key) {
|
|
1781
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
1782
|
+
}
|
|
1783
|
+
async has(key) {
|
|
1784
|
+
for (const cache2 of this.caches) {
|
|
1785
|
+
if (await cache2.has(key)) {
|
|
1786
|
+
return true;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
return false;
|
|
1790
|
+
}
|
|
1791
|
+
async increment(key, amount) {
|
|
1792
|
+
let rc = void 0;
|
|
1793
|
+
for (const cache2 of this.caches) {
|
|
1794
|
+
let rc2 = await cache2.increment(key, amount);
|
|
1795
|
+
if (rc === void 0) {
|
|
1796
|
+
rc = rc2;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
return rc;
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
|
|
1803
|
+
// src/factories.mts
|
|
1759
1804
|
var FlexibleFactory = class {
|
|
1760
1805
|
static {
|
|
1761
1806
|
__name(this, "FlexibleFactory");
|
|
@@ -1826,6 +1871,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
1826
1871
|
CacheProviderFactory.register("file", (opt) => {
|
|
1827
1872
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
1828
1873
|
});
|
|
1874
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
1875
|
+
const caches = [];
|
|
1876
|
+
for (const c of opt.caches) {
|
|
1877
|
+
caches.push(cache(c));
|
|
1878
|
+
}
|
|
1879
|
+
return new MultiCache(caches);
|
|
1880
|
+
});
|
|
1829
1881
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
1830
1882
|
return new import_neko_cache.DisabledCacheProvider();
|
|
1831
1883
|
});
|
|
@@ -2665,8 +2717,34 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2665
2717
|
executor = "";
|
|
2666
2718
|
packageManager = "";
|
|
2667
2719
|
linter = "";
|
|
2668
|
-
validation_library = ""
|
|
2669
|
-
|
|
2720
|
+
validation_library = import_clipanion10.Option.String("--validation-library", {
|
|
2721
|
+
description: "Validation library to use (yup, zod, none)",
|
|
2722
|
+
required: false
|
|
2723
|
+
});
|
|
2724
|
+
database_type = import_clipanion10.Option.String("--database-type", {
|
|
2725
|
+
description: "Database type to use (postgresql, mysql, sqlite)",
|
|
2726
|
+
required: false
|
|
2727
|
+
});
|
|
2728
|
+
cache_library = import_clipanion10.Option.String("--cache-library", {
|
|
2729
|
+
description: "Cache library to use (redis, memcached, none)",
|
|
2730
|
+
required: false
|
|
2731
|
+
});
|
|
2732
|
+
mailer_library = import_clipanion10.Option.String("--mailer-library", {
|
|
2733
|
+
description: "Mailer library to use (@aws-sdk/client-ses, nodemailer, none)",
|
|
2734
|
+
required: false
|
|
2735
|
+
});
|
|
2736
|
+
queue_library = import_clipanion10.Option.String("--queue-library", {
|
|
2737
|
+
description: "Queue library to use (@aws-sdk/client-sqs, @azure/service-bus, @google-cloud/pubsub, amqplib, redis, none)",
|
|
2738
|
+
required: false
|
|
2739
|
+
});
|
|
2740
|
+
storage_library = import_clipanion10.Option.String("--storage-library", {
|
|
2741
|
+
description: "Storage library to use (@aws-sdk/client-s3, @azure/storage-blob, @google-cloud/storage, basic-ftp, ssh2-sftp-client, none)",
|
|
2742
|
+
required: false
|
|
2743
|
+
});
|
|
2744
|
+
initGit = import_clipanion10.Option.Boolean("--git", {
|
|
2745
|
+
description: "Initialize a git repository (use --no-git to skip)",
|
|
2746
|
+
required: false
|
|
2747
|
+
});
|
|
2670
2748
|
async folderExists(folderPath) {
|
|
2671
2749
|
try {
|
|
2672
2750
|
const stats = await fs7.stat(folderPath);
|
|
@@ -2820,7 +2898,7 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2820
2898
|
await fs7.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
2821
2899
|
}
|
|
2822
2900
|
async setupGeneralPackages() {
|
|
2823
|
-
this.validation_library = await (0, import_prompts.select)({
|
|
2901
|
+
this.validation_library = this.validation_library ?? await (0, import_prompts.select)({
|
|
2824
2902
|
message: "Select a package you want for validation",
|
|
2825
2903
|
choices: [
|
|
2826
2904
|
{
|
|
@@ -2841,8 +2919,15 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2841
2919
|
}
|
|
2842
2920
|
]
|
|
2843
2921
|
});
|
|
2844
|
-
this.validation_library === "
|
|
2845
|
-
|
|
2922
|
+
if (this.validation_library === "yup" || this.validation_library === "zod") {
|
|
2923
|
+
await this.addPackage(this.validation_library);
|
|
2924
|
+
} else if (this.validation_library === "none") {
|
|
2925
|
+
} else {
|
|
2926
|
+
throw new Error(
|
|
2927
|
+
"unexpected validation library: " + this.validation_library + ". Valid options are: yup, zod, none"
|
|
2928
|
+
);
|
|
2929
|
+
}
|
|
2930
|
+
this.database_type = this.database_type ?? await (0, import_prompts.select)({
|
|
2846
2931
|
message: "Select a database type (you can add more databases later)",
|
|
2847
2932
|
choices: [
|
|
2848
2933
|
{
|
|
@@ -2868,6 +2953,179 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2868
2953
|
await this.addPackage("mysql2");
|
|
2869
2954
|
} else if (this.database_type === "sqlite") {
|
|
2870
2955
|
await this.addPackage("sqlite3");
|
|
2956
|
+
} else {
|
|
2957
|
+
throw new Error(
|
|
2958
|
+
"unexpected database type: " + this.database_type + ". Valid options are: postgresql, mysql, sqlite"
|
|
2959
|
+
);
|
|
2960
|
+
}
|
|
2961
|
+
this.cache_library = this.cache_library ?? await (0, import_prompts.select)({
|
|
2962
|
+
message: "Select a cache library",
|
|
2963
|
+
choices: [
|
|
2964
|
+
{
|
|
2965
|
+
name: "Redis",
|
|
2966
|
+
value: "redis",
|
|
2967
|
+
description: "Redis client for Node.js"
|
|
2968
|
+
},
|
|
2969
|
+
{
|
|
2970
|
+
name: "Memcached",
|
|
2971
|
+
value: "memcached",
|
|
2972
|
+
description: "Memcached client for Node.js"
|
|
2973
|
+
},
|
|
2974
|
+
new import_prompts.Separator(),
|
|
2975
|
+
{
|
|
2976
|
+
name: "None",
|
|
2977
|
+
value: "none",
|
|
2978
|
+
disabled: false
|
|
2979
|
+
}
|
|
2980
|
+
]
|
|
2981
|
+
});
|
|
2982
|
+
if (this.cache_library === "redis") {
|
|
2983
|
+
await this.addPackage("redis");
|
|
2984
|
+
} else if (this.cache_library === "memcached") {
|
|
2985
|
+
await this.addPackage("memcached");
|
|
2986
|
+
} else if (this.cache_library === "none") {
|
|
2987
|
+
} else {
|
|
2988
|
+
throw new Error(
|
|
2989
|
+
"unexpected cache library: " + this.cache_library + ". Valid options are: redis, memcached, none"
|
|
2990
|
+
);
|
|
2991
|
+
}
|
|
2992
|
+
this.mailer_library = this.mailer_library ?? await (0, import_prompts.select)({
|
|
2993
|
+
message: "Select a mailer library",
|
|
2994
|
+
choices: [
|
|
2995
|
+
{
|
|
2996
|
+
name: "AWS SES",
|
|
2997
|
+
value: "@aws-sdk/client-ses",
|
|
2998
|
+
description: "AWS SDK for JavaScript v3 - SES client"
|
|
2999
|
+
},
|
|
3000
|
+
{
|
|
3001
|
+
name: "Nodemailer",
|
|
3002
|
+
value: "nodemailer",
|
|
3003
|
+
description: "Send emails with Node.js"
|
|
3004
|
+
},
|
|
3005
|
+
new import_prompts.Separator(),
|
|
3006
|
+
{
|
|
3007
|
+
name: "None",
|
|
3008
|
+
value: "none",
|
|
3009
|
+
disabled: false
|
|
3010
|
+
}
|
|
3011
|
+
]
|
|
3012
|
+
});
|
|
3013
|
+
if (this.mailer_library === "@aws-sdk/client-ses") {
|
|
3014
|
+
await this.addPackage("@aws-sdk/client-ses");
|
|
3015
|
+
} else if (this.mailer_library === "nodemailer") {
|
|
3016
|
+
await this.addPackage("nodemailer");
|
|
3017
|
+
await this.addPackage("@types/nodemailer", true);
|
|
3018
|
+
} else if (this.mailer_library === "none") {
|
|
3019
|
+
} else {
|
|
3020
|
+
throw new Error(
|
|
3021
|
+
"unexpected mailer library: " + this.mailer_library + ". Valid options are: @aws-sdk/client-ses, nodemailer, none"
|
|
3022
|
+
);
|
|
3023
|
+
}
|
|
3024
|
+
this.queue_library = this.queue_library ?? await (0, import_prompts.select)({
|
|
3025
|
+
message: "Select a queue library",
|
|
3026
|
+
choices: [
|
|
3027
|
+
{
|
|
3028
|
+
name: "AWS SQS",
|
|
3029
|
+
value: "@aws-sdk/client-sqs",
|
|
3030
|
+
description: "AWS SDK for JavaScript v3 - SQS client"
|
|
3031
|
+
},
|
|
3032
|
+
{
|
|
3033
|
+
name: "Azure Service Bus",
|
|
3034
|
+
value: "@azure/service-bus",
|
|
3035
|
+
description: "Azure Service Bus client for Node.js"
|
|
3036
|
+
},
|
|
3037
|
+
{
|
|
3038
|
+
name: "Google Cloud Pub/Sub",
|
|
3039
|
+
value: "@google-cloud/pubsub",
|
|
3040
|
+
description: "Google Cloud Pub/Sub client for Node.js"
|
|
3041
|
+
},
|
|
3042
|
+
{
|
|
3043
|
+
name: "RabbitMQ (amqplib)",
|
|
3044
|
+
value: "amqplib",
|
|
3045
|
+
description: "AMQP 0-9-1 client for Node.js"
|
|
3046
|
+
},
|
|
3047
|
+
{
|
|
3048
|
+
name: "Redis",
|
|
3049
|
+
value: "redis",
|
|
3050
|
+
description: "Redis client for Node.js"
|
|
3051
|
+
},
|
|
3052
|
+
new import_prompts.Separator(),
|
|
3053
|
+
{
|
|
3054
|
+
name: "None",
|
|
3055
|
+
value: "none",
|
|
3056
|
+
disabled: false
|
|
3057
|
+
}
|
|
3058
|
+
]
|
|
3059
|
+
});
|
|
3060
|
+
if (this.queue_library === "@aws-sdk/client-sqs") {
|
|
3061
|
+
await this.addPackage("@aws-sdk/client-sqs");
|
|
3062
|
+
} else if (this.queue_library === "@azure/service-bus") {
|
|
3063
|
+
await this.addPackage("@azure/service-bus");
|
|
3064
|
+
} else if (this.queue_library === "@google-cloud/pubsub") {
|
|
3065
|
+
await this.addPackage("@google-cloud/pubsub");
|
|
3066
|
+
} else if (this.queue_library === "amqplib") {
|
|
3067
|
+
await this.addPackage("amqplib");
|
|
3068
|
+
await this.addPackage("@types/amqplib", true);
|
|
3069
|
+
} else if (this.queue_library === "redis") {
|
|
3070
|
+
await this.addPackage("redis");
|
|
3071
|
+
} else if (this.queue_library === "none") {
|
|
3072
|
+
} else {
|
|
3073
|
+
throw new Error(
|
|
3074
|
+
"unexpected queue library: " + this.queue_library + ". Valid options are: @aws-sdk/client-sqs, @azure/service-bus, @google-cloud/pubsub, amqplib, redis, none"
|
|
3075
|
+
);
|
|
3076
|
+
}
|
|
3077
|
+
this.storage_library = this.storage_library ?? await (0, import_prompts.select)({
|
|
3078
|
+
message: "Select a storage library",
|
|
3079
|
+
choices: [
|
|
3080
|
+
{
|
|
3081
|
+
name: "@aws-sdk/client-s3",
|
|
3082
|
+
value: "@aws-sdk/client-s3",
|
|
3083
|
+
description: "AWS SDK for JavaScript v3 - S3 client"
|
|
3084
|
+
},
|
|
3085
|
+
{
|
|
3086
|
+
name: "@azure/storage-blob",
|
|
3087
|
+
value: "@azure/storage-blob",
|
|
3088
|
+
description: "Azure Storage Blob client for Node.js"
|
|
3089
|
+
},
|
|
3090
|
+
{
|
|
3091
|
+
name: "@google-cloud/storage",
|
|
3092
|
+
value: "@google-cloud/storage",
|
|
3093
|
+
description: "Google Cloud Storage client for Node.js"
|
|
3094
|
+
},
|
|
3095
|
+
{
|
|
3096
|
+
name: "basic-ftp",
|
|
3097
|
+
value: "basic-ftp",
|
|
3098
|
+
description: "FTP client for Node.js"
|
|
3099
|
+
},
|
|
3100
|
+
{
|
|
3101
|
+
name: "ssh2-sftp-client",
|
|
3102
|
+
value: "ssh2-sftp-client",
|
|
3103
|
+
description: "SFTP client for Node.js"
|
|
3104
|
+
},
|
|
3105
|
+
new import_prompts.Separator(),
|
|
3106
|
+
{
|
|
3107
|
+
name: "None",
|
|
3108
|
+
value: "none",
|
|
3109
|
+
disabled: false
|
|
3110
|
+
}
|
|
3111
|
+
]
|
|
3112
|
+
});
|
|
3113
|
+
if (this.storage_library === "@aws-sdk/client-s3") {
|
|
3114
|
+
await this.addPackage("@aws-sdk/client-s3");
|
|
3115
|
+
} else if (this.storage_library === "@azure/storage-blob") {
|
|
3116
|
+
await this.addPackage("@azure/storage-blob");
|
|
3117
|
+
} else if (this.storage_library === "@google-cloud/storage") {
|
|
3118
|
+
await this.addPackage("@google-cloud/storage");
|
|
3119
|
+
} else if (this.storage_library === "basic-ftp") {
|
|
3120
|
+
await this.addPackage("basic-ftp");
|
|
3121
|
+
} else if (this.storage_library === "ssh2-sftp-client") {
|
|
3122
|
+
await this.addPackage("ssh2-sftp-client");
|
|
3123
|
+
await this.addPackage("@types/ssh2-sftp-client", true);
|
|
3124
|
+
} else if (this.storage_library === "none") {
|
|
3125
|
+
} else {
|
|
3126
|
+
throw new Error(
|
|
3127
|
+
"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"
|
|
3128
|
+
);
|
|
2871
3129
|
}
|
|
2872
3130
|
await this.addPackage("@devbro/pashmak tsconfig-paths dotenv ");
|
|
2873
3131
|
await this.addPackage(
|
|
@@ -2924,7 +3182,7 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2924
3182
|
});
|
|
2925
3183
|
}
|
|
2926
3184
|
async setupGit() {
|
|
2927
|
-
|
|
3185
|
+
this.initGit = this.initGit ?? await (0, import_prompts.select)({
|
|
2928
3186
|
message: "Initialize a git repository?",
|
|
2929
3187
|
choices: [
|
|
2930
3188
|
{
|
|
@@ -2939,7 +3197,7 @@ var CreateProjectCommand = class extends import_clipanion10.Command {
|
|
|
2939
3197
|
}
|
|
2940
3198
|
]
|
|
2941
3199
|
});
|
|
2942
|
-
if (initGit) {
|
|
3200
|
+
if (this.initGit) {
|
|
2943
3201
|
const gitignoreContent = [
|
|
2944
3202
|
"node_modules/",
|
|
2945
3203
|
"dist/",
|
|
@@ -592,6 +592,51 @@ var DatabaseTransport = class {
|
|
|
592
592
|
// src/factories.mts
|
|
593
593
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
594
594
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
595
|
+
|
|
596
|
+
// src/cache/MultiCache.mts
|
|
597
|
+
var MultiCache = class {
|
|
598
|
+
constructor(caches) {
|
|
599
|
+
this.caches = caches;
|
|
600
|
+
}
|
|
601
|
+
static {
|
|
602
|
+
__name(this, "MultiCache");
|
|
603
|
+
}
|
|
604
|
+
async get(key) {
|
|
605
|
+
for (const cache2 of this.caches) {
|
|
606
|
+
const value = await cache2.get(key);
|
|
607
|
+
if (value !== void 0) {
|
|
608
|
+
return value;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return void 0;
|
|
612
|
+
}
|
|
613
|
+
async put(key, value, ttl) {
|
|
614
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
615
|
+
}
|
|
616
|
+
async delete(key) {
|
|
617
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
618
|
+
}
|
|
619
|
+
async has(key) {
|
|
620
|
+
for (const cache2 of this.caches) {
|
|
621
|
+
if (await cache2.has(key)) {
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return false;
|
|
626
|
+
}
|
|
627
|
+
async increment(key, amount) {
|
|
628
|
+
let rc = void 0;
|
|
629
|
+
for (const cache2 of this.caches) {
|
|
630
|
+
let rc2 = await cache2.increment(key, amount);
|
|
631
|
+
if (rc === void 0) {
|
|
632
|
+
rc = rc2;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return rc;
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
// src/factories.mts
|
|
595
640
|
var FlexibleFactory = class {
|
|
596
641
|
static {
|
|
597
642
|
__name(this, "FlexibleFactory");
|
|
@@ -662,6 +707,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
662
707
|
CacheProviderFactory.register("file", (opt) => {
|
|
663
708
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
664
709
|
});
|
|
710
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
711
|
+
const caches = [];
|
|
712
|
+
for (const c of opt.caches) {
|
|
713
|
+
caches.push(cache(c));
|
|
714
|
+
}
|
|
715
|
+
return new MultiCache(caches);
|
|
716
|
+
});
|
|
665
717
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
666
718
|
return new import_neko_cache.DisabledCacheProvider();
|
|
667
719
|
});
|
|
@@ -592,6 +592,51 @@ var DatabaseTransport = class {
|
|
|
592
592
|
// src/factories.mts
|
|
593
593
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
594
594
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
595
|
+
|
|
596
|
+
// src/cache/MultiCache.mts
|
|
597
|
+
var MultiCache = class {
|
|
598
|
+
constructor(caches) {
|
|
599
|
+
this.caches = caches;
|
|
600
|
+
}
|
|
601
|
+
static {
|
|
602
|
+
__name(this, "MultiCache");
|
|
603
|
+
}
|
|
604
|
+
async get(key) {
|
|
605
|
+
for (const cache2 of this.caches) {
|
|
606
|
+
const value = await cache2.get(key);
|
|
607
|
+
if (value !== void 0) {
|
|
608
|
+
return value;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return void 0;
|
|
612
|
+
}
|
|
613
|
+
async put(key, value, ttl) {
|
|
614
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
615
|
+
}
|
|
616
|
+
async delete(key) {
|
|
617
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
618
|
+
}
|
|
619
|
+
async has(key) {
|
|
620
|
+
for (const cache2 of this.caches) {
|
|
621
|
+
if (await cache2.has(key)) {
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return false;
|
|
626
|
+
}
|
|
627
|
+
async increment(key, amount) {
|
|
628
|
+
let rc = void 0;
|
|
629
|
+
for (const cache2 of this.caches) {
|
|
630
|
+
let rc2 = await cache2.increment(key, amount);
|
|
631
|
+
if (rc === void 0) {
|
|
632
|
+
rc = rc2;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return rc;
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
// src/factories.mts
|
|
595
640
|
var FlexibleFactory = class {
|
|
596
641
|
static {
|
|
597
642
|
__name(this, "FlexibleFactory");
|
|
@@ -662,6 +707,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
662
707
|
CacheProviderFactory.register("file", (opt) => {
|
|
663
708
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
664
709
|
});
|
|
710
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
711
|
+
const caches = [];
|
|
712
|
+
for (const c of opt.caches) {
|
|
713
|
+
caches.push(cache(c));
|
|
714
|
+
}
|
|
715
|
+
return new MultiCache(caches);
|
|
716
|
+
});
|
|
665
717
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
666
718
|
return new import_neko_cache.DisabledCacheProvider();
|
|
667
719
|
});
|
|
@@ -1747,6 +1747,51 @@ var DatabaseTransport = class {
|
|
|
1747
1747
|
// src/factories.mts
|
|
1748
1748
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
1749
1749
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
1750
|
+
|
|
1751
|
+
// src/cache/MultiCache.mts
|
|
1752
|
+
var MultiCache = class {
|
|
1753
|
+
constructor(caches) {
|
|
1754
|
+
this.caches = caches;
|
|
1755
|
+
}
|
|
1756
|
+
static {
|
|
1757
|
+
__name(this, "MultiCache");
|
|
1758
|
+
}
|
|
1759
|
+
async get(key) {
|
|
1760
|
+
for (const cache2 of this.caches) {
|
|
1761
|
+
const value = await cache2.get(key);
|
|
1762
|
+
if (value !== void 0) {
|
|
1763
|
+
return value;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
return void 0;
|
|
1767
|
+
}
|
|
1768
|
+
async put(key, value, ttl) {
|
|
1769
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
1770
|
+
}
|
|
1771
|
+
async delete(key) {
|
|
1772
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
1773
|
+
}
|
|
1774
|
+
async has(key) {
|
|
1775
|
+
for (const cache2 of this.caches) {
|
|
1776
|
+
if (await cache2.has(key)) {
|
|
1777
|
+
return true;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
return false;
|
|
1781
|
+
}
|
|
1782
|
+
async increment(key, amount) {
|
|
1783
|
+
let rc = void 0;
|
|
1784
|
+
for (const cache2 of this.caches) {
|
|
1785
|
+
let rc2 = await cache2.increment(key, amount);
|
|
1786
|
+
if (rc === void 0) {
|
|
1787
|
+
rc = rc2;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
return rc;
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
// src/factories.mts
|
|
1750
1795
|
var FlexibleFactory = class {
|
|
1751
1796
|
static {
|
|
1752
1797
|
__name(this, "FlexibleFactory");
|
|
@@ -1817,6 +1862,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
1817
1862
|
CacheProviderFactory.register("file", (opt) => {
|
|
1818
1863
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
1819
1864
|
});
|
|
1865
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
1866
|
+
const caches = [];
|
|
1867
|
+
for (const c of opt.caches) {
|
|
1868
|
+
caches.push(cache(c));
|
|
1869
|
+
}
|
|
1870
|
+
return new MultiCache(caches);
|
|
1871
|
+
});
|
|
1820
1872
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
1821
1873
|
return new import_neko_cache.DisabledCacheProvider();
|
|
1822
1874
|
});
|
|
@@ -1749,6 +1749,51 @@ var DatabaseTransport = class {
|
|
|
1749
1749
|
// src/factories.mts
|
|
1750
1750
|
var import_neko_cache = require("@devbro/neko-cache");
|
|
1751
1751
|
var import_neko_storage = require("@devbro/neko-storage");
|
|
1752
|
+
|
|
1753
|
+
// src/cache/MultiCache.mts
|
|
1754
|
+
var MultiCache = class {
|
|
1755
|
+
constructor(caches) {
|
|
1756
|
+
this.caches = caches;
|
|
1757
|
+
}
|
|
1758
|
+
static {
|
|
1759
|
+
__name(this, "MultiCache");
|
|
1760
|
+
}
|
|
1761
|
+
async get(key) {
|
|
1762
|
+
for (const cache2 of this.caches) {
|
|
1763
|
+
const value = await cache2.get(key);
|
|
1764
|
+
if (value !== void 0) {
|
|
1765
|
+
return value;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
return void 0;
|
|
1769
|
+
}
|
|
1770
|
+
async put(key, value, ttl) {
|
|
1771
|
+
await Promise.all(this.caches.map((cache2) => cache2.put(key, value, ttl)));
|
|
1772
|
+
}
|
|
1773
|
+
async delete(key) {
|
|
1774
|
+
await Promise.all(this.caches.map((cache2) => cache2.delete(key)));
|
|
1775
|
+
}
|
|
1776
|
+
async has(key) {
|
|
1777
|
+
for (const cache2 of this.caches) {
|
|
1778
|
+
if (await cache2.has(key)) {
|
|
1779
|
+
return true;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
return false;
|
|
1783
|
+
}
|
|
1784
|
+
async increment(key, amount) {
|
|
1785
|
+
let rc = void 0;
|
|
1786
|
+
for (const cache2 of this.caches) {
|
|
1787
|
+
let rc2 = await cache2.increment(key, amount);
|
|
1788
|
+
if (rc === void 0) {
|
|
1789
|
+
rc = rc2;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
return rc;
|
|
1793
|
+
}
|
|
1794
|
+
};
|
|
1795
|
+
|
|
1796
|
+
// src/factories.mts
|
|
1752
1797
|
var FlexibleFactory = class {
|
|
1753
1798
|
static {
|
|
1754
1799
|
__name(this, "FlexibleFactory");
|
|
@@ -1819,6 +1864,13 @@ CacheProviderFactory.register("redis", (opt) => {
|
|
|
1819
1864
|
CacheProviderFactory.register("file", (opt) => {
|
|
1820
1865
|
return new import_neko_cache.FileCacheProvider(opt);
|
|
1821
1866
|
});
|
|
1867
|
+
CacheProviderFactory.register("multi", (opt) => {
|
|
1868
|
+
const caches = [];
|
|
1869
|
+
for (const c of opt.caches) {
|
|
1870
|
+
caches.push(cache(c));
|
|
1871
|
+
}
|
|
1872
|
+
return new MultiCache(caches);
|
|
1873
|
+
});
|
|
1822
1874
|
CacheProviderFactory.register("disabled", (opt) => {
|
|
1823
1875
|
return new import_neko_cache.DisabledCacheProvider();
|
|
1824
1876
|
});
|