@expressots/shared 3.0.0 → 4.0.0-preview.1

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.
Files changed (63) hide show
  1. package/README.md +31 -98
  2. package/lib/CHANGELOG.md +82 -65
  3. package/lib/README.md +31 -98
  4. package/lib/cjs/env/cli-options.js +2 -2
  5. package/lib/cjs/env/environment.js +10 -10
  6. package/lib/cjs/env/index.js +1 -1
  7. package/lib/cjs/index.js +4 -4
  8. package/lib/cjs/interfaces/index.js +3 -5
  9. package/lib/cjs/types/config/index.d.ts +1 -1
  10. package/lib/cjs/types/config/project-config.d.ts +5 -0
  11. package/lib/cjs/types/env/cli-options.d.ts +1 -1
  12. package/lib/cjs/types/env/env-options.d.ts +1 -1
  13. package/lib/cjs/types/env/environment.d.ts +1 -1
  14. package/lib/cjs/types/env/index.d.ts +2 -2
  15. package/lib/cjs/types/index.d.ts +4 -4
  16. package/lib/cjs/types/interfaces/application-express.interface.d.ts +9 -4
  17. package/lib/cjs/types/interfaces/console.interface.d.ts +6 -0
  18. package/lib/cjs/types/interfaces/index.d.ts +5 -5
  19. package/lib/cjs/types/interfaces/render/render.types.d.ts +1 -1
  20. package/lib/cjs/types/utils/compiler.d.ts +1 -1
  21. package/lib/cjs/types/utils/index.d.ts +1 -1
  22. package/lib/cjs/utils/index.js +2 -2
  23. package/lib/esm/config/index.js +1 -0
  24. package/lib/esm/config/project-config.js +1 -0
  25. package/lib/esm/env/cli-options.js +15 -0
  26. package/lib/esm/env/constants.js +10 -0
  27. package/lib/esm/env/env-options.js +19 -0
  28. package/lib/esm/env/environment.js +304 -0
  29. package/lib/esm/env/index.js +1 -0
  30. package/lib/esm/env/interfaces.js +1 -0
  31. package/lib/esm/index.mjs +4 -0
  32. package/lib/esm/interfaces/application-express.interface.js +1 -0
  33. package/lib/esm/interfaces/console.interface.js +1 -0
  34. package/lib/esm/interfaces/environment.interface.js +19 -0
  35. package/lib/esm/interfaces/index.js +1 -0
  36. package/lib/esm/interfaces/middleware.interface.js +1 -0
  37. package/lib/esm/interfaces/render/ejs.types.js +2 -0
  38. package/lib/esm/interfaces/render/render.types.js +20 -0
  39. package/lib/esm/package.json +3 -0
  40. package/lib/esm/types/config/index.d.ts +1 -0
  41. package/lib/esm/types/config/project-config.d.ts +43 -0
  42. package/lib/esm/types/env/cli-options.d.ts +7 -0
  43. package/lib/esm/types/env/constants.d.ts +10 -0
  44. package/lib/esm/types/env/env-options.d.ts +9 -0
  45. package/lib/esm/types/env/environment.d.ts +83 -0
  46. package/lib/esm/types/env/index.d.ts +2 -0
  47. package/lib/esm/types/env/interfaces.d.ts +71 -0
  48. package/lib/esm/types/index.d.ts +4 -0
  49. package/lib/esm/types/interfaces/application-express.interface.d.ts +58 -0
  50. package/lib/esm/types/interfaces/console.interface.d.ts +14 -0
  51. package/lib/esm/types/interfaces/environment.interface.d.ts +37 -0
  52. package/lib/esm/types/interfaces/index.d.ts +5 -0
  53. package/lib/esm/types/interfaces/middleware.interface.d.ts +7 -0
  54. package/lib/esm/types/interfaces/render/ejs.types.d.ts +169 -0
  55. package/lib/esm/types/interfaces/render/render.types.d.ts +71 -0
  56. package/lib/esm/types/utils/compiler.d.ts +17 -0
  57. package/lib/esm/types/utils/index.d.ts +1 -0
  58. package/lib/esm/types/utils/logger.d.ts +19 -0
  59. package/lib/esm/utils/compiler.js +69 -0
  60. package/lib/esm/utils/index.js +1 -0
  61. package/lib/esm/utils/logger.js +60 -0
  62. package/lib/package.json +154 -147
  63. package/package.json +154 -147
@@ -1,4 +1,4 @@
1
- export * from "./config";
2
- export * from "./env";
3
- export * from "./interfaces";
4
- export * from "./utils";
1
+ export * from "./config/index.js";
2
+ export * from "./env/index.js";
3
+ export * from "./interfaces/index.js";
4
+ export * from "./utils/index.js";
@@ -1,7 +1,6 @@
1
1
  import { Server as HTTPServer } from "http";
2
- import { IConsoleMessage } from "./console.interface";
3
- import { Environment, IEnvironment } from "./environment.interface";
4
- import { RenderEngine } from "./render/render.types";
2
+ import { IConsoleMessage } from "./console.interface.js";
3
+ import { RenderEngine } from "./render/render.types.js";
5
4
  /**
6
5
  * Namespace for the Server Application.
7
6
  * @namespace Server
@@ -12,7 +11,6 @@ export declare namespace Server {
12
11
  * Interface for the WebServer application implementation.
13
12
  */
14
13
  interface IWebServer {
15
- initEnvironment(environment: Environment, options?: IEnvironment): Promise<void>;
16
14
  listen(port: number | string, appInfo?: IConsoleMessage): Promise<IWebServerPublic>;
17
15
  setEngine<T extends RenderEngine.EngineOptions>(engine: RenderEngine.Engine, options?: T): Promise<void>;
18
16
  }
@@ -45,6 +43,13 @@ export declare namespace Server {
45
43
  * @public API
46
44
  */
47
45
  getHttpServer(): Promise<HTTPServer>;
46
+ /**
47
+ * Get the port the server is listening on.
48
+ * Useful for dynamic port assignment (port: 0) in testing scenarios.
49
+ * @returns The actual port number the server is bound to.
50
+ * @public API
51
+ */
52
+ getPort(): Promise<number>;
48
53
  }
49
54
  }
50
55
  export type IWebServer = Server.IWebServer;
@@ -5,4 +5,10 @@
5
5
  export interface IConsoleMessage {
6
6
  appName: string;
7
7
  appVersion: string;
8
+ apiVersions?: Array<string>;
9
+ /** CI environment detection info (for bootstrap logging) */
10
+ ciDetection?: {
11
+ detected: boolean;
12
+ platform?: string;
13
+ };
8
14
  }
@@ -1,5 +1,5 @@
1
- export { RenderEngine } from "./render/render.types";
2
- export { IConsoleMessage } from "./console.interface";
3
- export { IExpressoMiddleware } from "./middleware.interface";
4
- export { Environment, IEnvironment, Env } from "./environment.interface";
5
- export { IWebServer, IWebServerBuilder, IWebServerConstructor, IWebServerPublic, Server, } from "./application-express.interface";
1
+ export { RenderEngine } from "./render/render.types.js";
2
+ export type { IConsoleMessage } from "./console.interface.js";
3
+ export type { IExpressoMiddleware } from "./middleware.interface.js";
4
+ export type { Environment, IEnvironment, Env } from "./environment.interface.js";
5
+ export { IWebServer, IWebServerBuilder, IWebServerConstructor, IWebServerPublic, Server, } from "./application-express.interface.js";
@@ -1,4 +1,4 @@
1
- import { Options } from "./ejs.types";
1
+ import { Options } from "./ejs.types.js";
2
2
  /**
3
3
  * The Render namespace contains all the types and interfaces related to rendering views.
4
4
  * @namespace Render
@@ -1,5 +1,5 @@
1
1
  import { Service } from "ts-node";
2
- import { ExpressoConfig } from "../config";
2
+ import { ExpressoConfig } from "../config/index.js";
3
3
  export declare function printError(message: string, component: string): void;
4
4
  /**
5
5
  * Singleton compiler class
@@ -1 +1 @@
1
- export { Compiler } from "./compiler";
1
+ export { Compiler } from "./compiler.js";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Compiler = void 0;
4
- var compiler_1 = require("./compiler");
5
- Object.defineProperty(exports, "Compiler", { enumerable: true, get: function () { return compiler_1.Compiler; } });
4
+ var compiler_js_1 = require("./compiler.js");
5
+ Object.defineProperty(exports, "Compiler", { enumerable: true, get: function () { return compiler_js_1.Compiler; } });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { ENV_VAR_REGEX } from "./constants.js";
2
+ /**
3
+ * Matches the options passed in the command line
4
+ * @param args - The arguments passed in the command line
5
+ * @returns The options passed in the command line
6
+ */
7
+ export function optionMatcher(args) {
8
+ return args.reduce((previous, current) => {
9
+ const matches = current.match(ENV_VAR_REGEX);
10
+ if (matches) {
11
+ previous[matches[1]] = matches[2];
12
+ }
13
+ return previous;
14
+ }, {});
15
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * LINE_REGEX is a regular expression that matches a line in a .env file.
3
+ * It is used to parse the content of the .env file.
4
+ */
5
+ export const LINE_REGEX = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
6
+ /**
7
+ * ENV_VAR_REGEX is a regular expression that matches an environment variable in the command line.
8
+ * It is used to parse the options passed in the command line.
9
+ */
10
+ export const ENV_VAR_REGEX = /^dotenv_config_(encoding|path|debug|override|vaultEnvKey)=(.+)$/;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The options for the dotenv configuration.
3
+ */
4
+ export const OPTIONS = {};
5
+ if (process.env.DOTENV_CONFIG_ENCODING != null) {
6
+ OPTIONS.encoding = process.env.DOTENV_CONFIG_ENCODING;
7
+ }
8
+ if (process.env.DOTENV_CONFIG_PATH != null) {
9
+ OPTIONS.path = process.env.DOTENV_CONFIG_PATH;
10
+ }
11
+ if (process.env.DOTENV_CONFIG_DEBUG != null) {
12
+ OPTIONS.debug = process.env.DOTENV_CONFIG_DEBUG === "true";
13
+ }
14
+ if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
15
+ OPTIONS.override = process.env.DOTENV_CONFIG_OVERRIDE === "true";
16
+ }
17
+ if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
18
+ OPTIONS.vaultEnvKey = process.env.DOTENV_CONFIG_DOTENV_KEY;
19
+ }
@@ -0,0 +1,304 @@
1
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import fs from "fs";
4
+ import path from "path";
5
+ import os from "os";
6
+ import crypto from "crypto";
7
+ import { LINE_REGEX } from "./constants.js";
8
+ import { log, LogLevel } from "../utils/logger.js";
9
+ /**
10
+ * Module to parse the .env.vault file
11
+ * @param options - The configuration options
12
+ * @returns The parsed object
13
+ */
14
+ function _parseVault(options) {
15
+ const vaultPath = _vaultPath(options);
16
+ const result = configDotenv({ path: vaultPath });
17
+ if (!result.parsed) {
18
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
19
+ err.name = "MISSING_DATA";
20
+ throw err;
21
+ }
22
+ //DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod, // dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
23
+ const keys = _dotenvKey(options).split(",");
24
+ const length = keys.length;
25
+ let decrypted = "";
26
+ for (let i = 0; i < length; i++) {
27
+ try {
28
+ const key = keys[i].trim();
29
+ const attrs = _instructions(result, key);
30
+ decrypted = decrypt(attrs.ciphertext, attrs.key);
31
+ break;
32
+ }
33
+ catch (error) {
34
+ if (i + 1 >= length) {
35
+ throw error;
36
+ }
37
+ }
38
+ }
39
+ return parse(decrypted);
40
+ }
41
+ /**
42
+ * Module to verify and return the .env.vault file path
43
+ * @param options - The configuration options
44
+ * @returns The .env.vault file path
45
+ */
46
+ function _vaultPath(options) {
47
+ let possibleVaultPath = null;
48
+ if (options && options.path && options.path.length > 0) {
49
+ if (Array.isArray(options.path)) {
50
+ for (const filepath of options.path) {
51
+ if (fs.existsSync(filepath)) {
52
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
53
+ }
54
+ }
55
+ }
56
+ else {
57
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
58
+ }
59
+ }
60
+ else {
61
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
62
+ }
63
+ if (fs.existsSync(possibleVaultPath)) {
64
+ return possibleVaultPath;
65
+ }
66
+ return null;
67
+ }
68
+ /**
69
+ * Module to verify and return the DOTENV_KEY vault key
70
+ * @param options - The configuration options
71
+ * @returns The DOTENV_KEY as a string
72
+ */
73
+ function _dotenvKey(options) {
74
+ if (options && options.vaultEnvKey && options.vaultEnvKey.length > 0) {
75
+ return options.vaultEnvKey;
76
+ }
77
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
78
+ return process.env.DOTENV_KEY;
79
+ }
80
+ return "";
81
+ }
82
+ /**
83
+ * Module to get instructions for decrypting the .env.vault file
84
+ * @param result -
85
+ * @param dotenvKey
86
+ * @returns
87
+ */
88
+ function _instructions(result, dotenvKey) {
89
+ let uri = null;
90
+ try {
91
+ uri = new URL(dotenvKey);
92
+ }
93
+ catch (error) {
94
+ if (error.code === "ERR_INVALID_URL") {
95
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
96
+ err.code = "INVALID_DOTENV_KEY";
97
+ throw err;
98
+ }
99
+ throw error;
100
+ }
101
+ // Get decrypt key
102
+ const key = uri.password;
103
+ if (!key) {
104
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
105
+ err.code = "INVALID_DOTENV_KEY";
106
+ throw err;
107
+ }
108
+ // Get environment
109
+ const environment = uri.searchParams.get("environment");
110
+ if (!environment) {
111
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
112
+ err.code = "INVALID_DOTENV_KEY";
113
+ throw err;
114
+ }
115
+ // Get ciphertext payload
116
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
117
+ const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
118
+ if (!ciphertext) {
119
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
120
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
121
+ throw err;
122
+ }
123
+ return { ciphertext, key };
124
+ }
125
+ /**
126
+ * Module responsible to resolve home path
127
+ * @param envPath - The path to resolve
128
+ * @returns The resolved path
129
+ */
130
+ function _resolveHome(envPath) {
131
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
132
+ }
133
+ /**
134
+ * Module to load environment variables from .env.vault file
135
+ * @param options - The configuration options
136
+ * @returns The parsed object
137
+ */
138
+ export function _configVault(options) {
139
+ log("Loading env from encrypted .env.vault");
140
+ const parsed = _parseVault(options);
141
+ let processEnv = process.env;
142
+ if (options && options.envObject != null) {
143
+ processEnv = options.envObject;
144
+ }
145
+ populate(processEnv, parsed, options);
146
+ return { parsed };
147
+ }
148
+ /**
149
+ * Module to load environment variables from .env file
150
+ * @param options - The configuration options
151
+ * @returns The parsed object
152
+ * @public API
153
+ */
154
+ export function config(options) {
155
+ if (_dotenvKey(options).length === 0) {
156
+ return configDotenv(options);
157
+ }
158
+ const vaultPath = _vaultPath(options);
159
+ if (!vaultPath) {
160
+ const expected = path.resolve(process.cwd(), ".env.vault");
161
+ log(`You set DOTENV_KEY but no .env.vault file was found (expected at ${expected}). Did you forget to build it?`, LogLevel.Warn);
162
+ return configDotenv(options);
163
+ }
164
+ return _configVault(options);
165
+ }
166
+ /**
167
+ * Module to load environment variables from .env file
168
+ * @param options - The configuration options
169
+ * @returns The parsed object
170
+ * @public API
171
+ */
172
+ export function configDotenv(options) {
173
+ const dotenvPath = path.resolve(process.cwd(), String(options?.path ?? ".env"));
174
+ const encoding = (options.encoding ?? "utf8");
175
+ const debug = !!options.debug;
176
+ const paths = Array.isArray(options.path)
177
+ ? options.path.map(_resolveHome)
178
+ : [_resolveHome(dotenvPath)];
179
+ const parsed = {};
180
+ let lastError;
181
+ for (const envPath of paths) {
182
+ try {
183
+ const fileContent = fs.readFileSync(envPath, { encoding });
184
+ const parsedContent = parse(fileContent);
185
+ populate(process.env, parsedContent, options);
186
+ }
187
+ catch (error) {
188
+ lastError = error;
189
+ if (debug) {
190
+ log(`Failed to load ${envPath} file with error: ${error.message}`, LogLevel.Debug);
191
+ }
192
+ }
193
+ }
194
+ return { parsed, error: lastError };
195
+ }
196
+ /**
197
+ * Module to load environment variables from .env file
198
+ * @param envFile - The source of the .env file
199
+ * @returns The parsed object
200
+ * @public API
201
+ */
202
+ export function parse(envFile) {
203
+ const obj = {};
204
+ const lines = envFile.toString().replace(/\r\n?/gm, "\n");
205
+ let match;
206
+ while ((match = LINE_REGEX.exec(lines)) != null) {
207
+ const key = match[1].trim();
208
+ let value = match[2]?.trim() ?? "";
209
+ if (["'", '"', "`"].includes(value[0])) {
210
+ value = value.slice(1, -1);
211
+ }
212
+ value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
213
+ if (match[2]?.[0] === '"') {
214
+ value = value.replace(/\\n/g, "\n").replace(/\\r/g, "\r");
215
+ }
216
+ obj[key] = value;
217
+ }
218
+ return obj;
219
+ }
220
+ /**
221
+ * Decrypts a base64 encoded string
222
+ * @param encrypted - The base64 encoded string to decrypt
223
+ * @param keyStr - The key to use for decryption
224
+ * @returns The decrypted string
225
+ * @public API
226
+ */
227
+ export function decrypt(encrypted, keyStr) {
228
+ const key = Buffer.from(keyStr.slice(-64), "hex");
229
+ let ciphertext = Buffer.from(encrypted, "base64");
230
+ const nonce = ciphertext.subarray(0, 12);
231
+ const authTag = ciphertext.subarray(-16);
232
+ ciphertext = ciphertext.subarray(12, -16);
233
+ try {
234
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
235
+ aesgcm.setAuthTag(authTag);
236
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
237
+ }
238
+ catch (error) {
239
+ const isRange = error instanceof RangeError;
240
+ const invalidKeyLength = error.message === "Invalid key length";
241
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
242
+ if (isRange || invalidKeyLength) {
243
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
244
+ err.name = "INVALID_DOTENV_KEY";
245
+ throw err;
246
+ }
247
+ else if (decryptionFailed) {
248
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
249
+ err.name = "DECRYPTION_FAILED";
250
+ throw err;
251
+ }
252
+ else {
253
+ throw error;
254
+ }
255
+ }
256
+ }
257
+ /**
258
+ * Populates the environment with the given parsed object
259
+ * @param envObject - The object to populate the environment with (e.g. process.env)
260
+ * @param parsed - The parsed object
261
+ * @param options - The configuration options
262
+ * @public API
263
+ */
264
+ export function populate(envObject, // Usually process.env
265
+ parsed, options = {}) {
266
+ const debug = Boolean(options && options.debug);
267
+ const override = Boolean(options && options.override);
268
+ if (typeof parsed !== "object") {
269
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
270
+ err.name = "OBJECT_REQUIRED";
271
+ throw err;
272
+ }
273
+ // Set process.env (envObject)
274
+ for (const key of Object.keys(parsed)) {
275
+ const parsedValue = parsed[key];
276
+ // Decide whether to override existing env var or not
277
+ if (Object.prototype.hasOwnProperty.call(envObject, key)) {
278
+ if (override) {
279
+ envObject[key] = parsedValue;
280
+ if (debug) {
281
+ log(`"${key}" was overwritten to "${parsedValue}"`, LogLevel.Debug);
282
+ }
283
+ }
284
+ else if (debug) {
285
+ log(`"${key}" was NOT overwritten (already exists)`, LogLevel.Debug);
286
+ }
287
+ }
288
+ else {
289
+ // Variable doesn't exist in process.env, so set it
290
+ envObject[key] = parsedValue;
291
+ if (debug) {
292
+ log(`"${key}" was set to "${parsedValue}"`, LogLevel.Debug);
293
+ }
294
+ }
295
+ }
296
+ // Final debug log to ensure variables are correctly populated
297
+ if (debug) {
298
+ console.log("Final process.env object:", envObject);
299
+ }
300
+ }
301
+ /**
302
+ * Test swap for private functions
303
+ */
304
+ export { _parseVault, _vaultPath, _dotenvKey, _instructions, _resolveHome };
@@ -0,0 +1 @@
1
+ export * from "./environment.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from "./config/index.js";
2
+ export * from "./env/index.js";
3
+ export * from "./interfaces/index.js";
4
+ export * from "./utils/index.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ /**
3
+ * The Environment namespace contains all the types and interfaces related to environment configuration.
4
+ * @namespace Environment
5
+ * @public API
6
+ */
7
+ export var Env;
8
+ (function (Env) {
9
+ /**
10
+ * Enum representing possible server environments.
11
+ * @public API
12
+ */
13
+ let ServerEnvironment;
14
+ (function (ServerEnvironment) {
15
+ ServerEnvironment["Development"] = "development";
16
+ ServerEnvironment["Production"] = "production";
17
+ ServerEnvironment["Remote"] = "remote";
18
+ })(ServerEnvironment = Env.ServerEnvironment || (Env.ServerEnvironment = {}));
19
+ })(Env || (Env = {}));
@@ -0,0 +1 @@
1
+ export { RenderEngine } from "./render/render.types.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The Render namespace contains all the types and interfaces related to rendering views.
3
+ * @namespace Render
4
+ * @public API
5
+ */
6
+ export var RenderEngine;
7
+ (function (RenderEngine) {
8
+ /**
9
+ * The supported view engines.
10
+ * @enum {string} Engine - The supported view engines.
11
+ * @readonly - This enum is read-only.
12
+ * @public API
13
+ */
14
+ let Engine;
15
+ (function (Engine) {
16
+ Engine["HBS"] = "hbs";
17
+ Engine["EJS"] = "ejs";
18
+ Engine["PUG"] = "pug";
19
+ })(Engine = RenderEngine.Engine || (RenderEngine.Engine = {}));
20
+ })(RenderEngine || (RenderEngine = {}));
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1 @@
1
+ export { Pattern, ExpressoConfig } from "./project-config.js";
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Enum representing different string patterns.
3
+ *
4
+ * - LOWER_CASE: Represents strings in all lowercase letters. E.g. "hello"
5
+ * - KEBAB_CASE: Represents strings separated by hyphens. E.g. "hello-world"
6
+ * - PASCAL_CASE: Represents strings where the first letter of each word is capitalized. E.g. "HelloWorld"
7
+ * - CAMEL_CASE: Represents strings where the first letter of the first word is lowercase and the first letter of subsequent words are capitalized. E.g. "helloWorld"
8
+ * @public API
9
+ */
10
+ export declare const enum Pattern {
11
+ LOWER_CASE = "lowercase",
12
+ KEBAB_CASE = "kebab-case",
13
+ PASCAL_CASE = "PascalCase",
14
+ CAMEL_CASE = "camelCase"
15
+ }
16
+ /**
17
+ * The configuration object for the Expresso CLI.
18
+ * @property {Pattern} scaffoldPattern - The pattern to use when scaffolding files.
19
+ * @property {string} sourceRoot - The root directory for the source files.
20
+ * @property {boolean} opinionated - Whether or not to use the opinionated configuration.
21
+ * @property {IProviders} providers - Specific configuration for each provider added.
22
+ * @public API
23
+ */
24
+ export interface ExpressoConfig {
25
+ scaffoldPattern: Pattern;
26
+ sourceRoot: string;
27
+ entryPoint: string;
28
+ opinionated: boolean;
29
+ scaffoldSchematics?: {
30
+ entity?: string;
31
+ controller?: string;
32
+ usecase?: string;
33
+ dto?: string;
34
+ module?: string;
35
+ provider?: string;
36
+ middleware?: string;
37
+ interceptor?: string;
38
+ event?: string;
39
+ handler?: string;
40
+ guard?: string;
41
+ config?: string;
42
+ };
43
+ }
@@ -0,0 +1,7 @@
1
+ import { IConfigOptions } from "./interfaces.js";
2
+ /**
3
+ * Matches the options passed in the command line
4
+ * @param args - The arguments passed in the command line
5
+ * @returns The options passed in the command line
6
+ */
7
+ export declare function optionMatcher(args: Array<string>): IConfigOptions;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * LINE_REGEX is a regular expression that matches a line in a .env file.
3
+ * It is used to parse the content of the .env file.
4
+ */
5
+ export declare const LINE_REGEX: RegExp;
6
+ /**
7
+ * ENV_VAR_REGEX is a regular expression that matches an environment variable in the command line.
8
+ * It is used to parse the options passed in the command line.
9
+ */
10
+ export declare const ENV_VAR_REGEX: RegExp;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Module EnvOptions
3
+ * Responsible for setting the options for the dotenv configuration if provided otherwise it will use the default values.
4
+ */
5
+ import { IConfigOptions } from "./interfaces.js";
6
+ /**
7
+ * The options for the dotenv configuration.
8
+ */
9
+ export declare const OPTIONS: IConfigOptions;