@akanjs/nest 0.0.62 → 0.0.64

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/nest",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,7 +1,7 @@
1
1
  import { BackendEnv, type BaseEnv } from "@akanjs/base";
2
2
  import { SshOptions } from "tunnel-ssh";
3
- export declare const generateJwtSecret: (appName: string, environment: "debug" | "develop" | "main" | "testing") => string;
4
- export declare const generateAeskey: (appName: string, environment: "debug" | "develop" | "main" | "testing") => string;
3
+ export declare const generateJwtSecret: (appName: string, environment: BaseEnv["environment"]) => string;
4
+ export declare const generateAeskey: (appName: string, environment: BaseEnv["environment"]) => string;
5
5
  interface RedisEnv {
6
6
  appName: string;
7
7
  environment: BaseEnv["environment"];
@@ -77,6 +77,8 @@ const createDatabaseTunnel = async ({
77
77
  const generateRedisUri = async ({ appName, environment, operationMode, sshOptions }) => {
78
78
  if (process.env.REDIS_URI)
79
79
  return process.env.REDIS_URI;
80
+ else if (environment === "local")
81
+ return "redis://localhost:6379";
80
82
  const port = operationMode === "local" ? DEFAULT_CLOUD_PORT + getEnvironmentPort(environment) + getServicePort("redis") : 6379;
81
83
  const url = operationMode === "cloud" ? `redis-svc.${appName}-${environment}.svc.cluster.local` : operationMode === "local" ? await createDatabaseTunnel({ appName, environment, type: "redis", port, sshOptions }) : "localhost:6379";
82
84
  const uri = `redis://${url}`;
@@ -90,14 +92,16 @@ const generateMongoUri = async ({
90
92
  password,
91
93
  sshOptions
92
94
  }) => {
95
+ const dbName = `${appName}-${environment}`;
93
96
  if (process.env.MONGO_URI)
94
97
  return process.env.MONGO_URI;
98
+ else if (environment === "local")
99
+ return `mongodb://localhost:27017/${dbName}`;
95
100
  const record = operationMode === "cloud" ? "mongodb+srv" : "mongodb";
96
101
  const port = operationMode === "local" ? DEFAULT_CLOUD_PORT + getEnvironmentPort(environment) + getServicePort("mongo") : 27017;
97
102
  const url = operationMode === "cloud" ? `mongo-svc.${appName}-${environment}.svc.cluster.local` : operationMode === "local" ? await createDatabaseTunnel({ appName, environment, type: "mongo", port, sshOptions }) : "localhost:27017";
98
103
  const usernameEncoded = password ? encodeURIComponent(username) : null;
99
104
  const passwordEncoded = password ? encodeURIComponent(password) : null;
100
- const dbName = `${appName}-${environment}`;
101
105
  const directConnection = operationMode === "cloud" ? false : true;
102
106
  const authInfo = usernameEncoded ? `${usernameEncoded}:${passwordEncoded}@` : "";
103
107
  const uri = `${record}://${authInfo}${url}/${dbName}?authSource=${dbName}&readPreference=primary&ssl=false&retryWrites=true&directConnection=${directConnection}`;
@@ -106,6 +110,8 @@ const generateMongoUri = async ({
106
110
  const generateMeiliUri = ({ appName, environment, operationMode }) => {
107
111
  if (process.env.MEILI_URI)
108
112
  return process.env.MEILI_URI;
113
+ else if (environment === "local")
114
+ return "http://localhost:7700";
109
115
  const protocol = operationMode === "local" ? "https" : "http";
110
116
  const url = operationMode === "cloud" ? `meili-0.meili-svc.${appName}-${environment}.svc.cluster.local:7700` : operationMode === "local" ? `${appName}-${environment}.${import_base.baseEnv.serveDomain}/search` : "localhost:7700";
111
117
  const uri = `${protocol}://${url}`;
@@ -123,6 +129,10 @@ const generateHost = (env) => {
123
129
  return `${env.appName}-${env.environment}.${import_base.baseEnv.serveDomain}`;
124
130
  };
125
131
  const generateMeiliKey = ({ appName, environment }) => {
132
+ if (process.env.MEILI_MASTER_KEY)
133
+ return process.env.MEILI_MASTER_KEY;
134
+ else if (environment === "local")
135
+ return "masterKey";
126
136
  return `meilisearch-key-${appName}-${environment}`;
127
137
  };
128
138
  // Annotate the CommonJS export names for ESM import in node:
@@ -48,6 +48,8 @@ const createDatabaseTunnel = async ({
48
48
  const generateRedisUri = async ({ appName, environment, operationMode, sshOptions }) => {
49
49
  if (process.env.REDIS_URI)
50
50
  return process.env.REDIS_URI;
51
+ else if (environment === "local")
52
+ return "redis://localhost:6379";
51
53
  const port = operationMode === "local" ? DEFAULT_CLOUD_PORT + getEnvironmentPort(environment) + getServicePort("redis") : 6379;
52
54
  const url = operationMode === "cloud" ? `redis-svc.${appName}-${environment}.svc.cluster.local` : operationMode === "local" ? await createDatabaseTunnel({ appName, environment, type: "redis", port, sshOptions }) : "localhost:6379";
53
55
  const uri = `redis://${url}`;
@@ -61,14 +63,16 @@ const generateMongoUri = async ({
61
63
  password,
62
64
  sshOptions
63
65
  }) => {
66
+ const dbName = `${appName}-${environment}`;
64
67
  if (process.env.MONGO_URI)
65
68
  return process.env.MONGO_URI;
69
+ else if (environment === "local")
70
+ return `mongodb://localhost:27017/${dbName}`;
66
71
  const record = operationMode === "cloud" ? "mongodb+srv" : "mongodb";
67
72
  const port = operationMode === "local" ? DEFAULT_CLOUD_PORT + getEnvironmentPort(environment) + getServicePort("mongo") : 27017;
68
73
  const url = operationMode === "cloud" ? `mongo-svc.${appName}-${environment}.svc.cluster.local` : operationMode === "local" ? await createDatabaseTunnel({ appName, environment, type: "mongo", port, sshOptions }) : "localhost:27017";
69
74
  const usernameEncoded = password ? encodeURIComponent(username) : null;
70
75
  const passwordEncoded = password ? encodeURIComponent(password) : null;
71
- const dbName = `${appName}-${environment}`;
72
76
  const directConnection = operationMode === "cloud" ? false : true;
73
77
  const authInfo = usernameEncoded ? `${usernameEncoded}:${passwordEncoded}@` : "";
74
78
  const uri = `${record}://${authInfo}${url}/${dbName}?authSource=${dbName}&readPreference=primary&ssl=false&retryWrites=true&directConnection=${directConnection}`;
@@ -77,6 +81,8 @@ const generateMongoUri = async ({
77
81
  const generateMeiliUri = ({ appName, environment, operationMode }) => {
78
82
  if (process.env.MEILI_URI)
79
83
  return process.env.MEILI_URI;
84
+ else if (environment === "local")
85
+ return "http://localhost:7700";
80
86
  const protocol = operationMode === "local" ? "https" : "http";
81
87
  const url = operationMode === "cloud" ? `meili-0.meili-svc.${appName}-${environment}.svc.cluster.local:7700` : operationMode === "local" ? `${appName}-${environment}.${baseEnv.serveDomain}/search` : "localhost:7700";
82
88
  const uri = `${protocol}://${url}`;
@@ -94,6 +100,10 @@ const generateHost = (env) => {
94
100
  return `${env.appName}-${env.environment}.${baseEnv.serveDomain}`;
95
101
  };
96
102
  const generateMeiliKey = ({ appName, environment }) => {
103
+ if (process.env.MEILI_MASTER_KEY)
104
+ return process.env.MEILI_MASTER_KEY;
105
+ else if (environment === "local")
106
+ return "masterKey";
97
107
  return `meilisearch-key-${appName}-${environment}`;
98
108
  };
99
109
  export {