@adonisjs/env 4.1.3-0 → 4.1.5-0
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/LICENSE.md +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/src/exceptions.d.ts +24 -0
- package/build/src/{exceptions/invalid_env_variables.js → exceptions.js} +4 -4
- package/build/src/validator.js +6 -6
- package/package.json +5 -5
- package/build/src/exceptions/invalid_env_variables.d.ts +0 -6
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright (c) 2023 AdonisJS Framework
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Env } from './src/env.js';
|
|
2
2
|
export { EnvParser } from './src/parser.js';
|
|
3
3
|
export { EnvLoader } from './src/loader.js';
|
|
4
|
+
export * as errors from './src/exceptions.js';
|
|
4
5
|
export { EnvProcessor } from './src/processor.js';
|
|
5
|
-
export { InvalidEnvVariablesException } from './src/exceptions/invalid_env_variables.js';
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Env } from './src/env.js';
|
|
2
2
|
export { EnvParser } from './src/parser.js';
|
|
3
3
|
export { EnvLoader } from './src/loader.js';
|
|
4
|
+
export * as errors from './src/exceptions.js';
|
|
4
5
|
export { EnvProcessor } from './src/processor.js';
|
|
5
|
-
export { InvalidEnvVariablesException } from './src/exceptions/invalid_env_variables.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
export declare const E_INVALID_ENV_VARIABLES: {
|
|
3
|
+
new (message?: string | undefined, options?: (ErrorOptions & {
|
|
4
|
+
code?: string | undefined;
|
|
5
|
+
status?: number | undefined;
|
|
6
|
+
}) | undefined): {
|
|
7
|
+
help: string;
|
|
8
|
+
name: string;
|
|
9
|
+
code?: string | undefined;
|
|
10
|
+
status: number;
|
|
11
|
+
toString(): string;
|
|
12
|
+
readonly [Symbol.toStringTag]: string;
|
|
13
|
+
message: string;
|
|
14
|
+
stack?: string | undefined;
|
|
15
|
+
cause?: unknown;
|
|
16
|
+
};
|
|
17
|
+
message: string;
|
|
18
|
+
code: string;
|
|
19
|
+
help?: string | undefined;
|
|
20
|
+
status?: number | undefined;
|
|
21
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
22
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
23
|
+
stackTraceLimit: number;
|
|
24
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Exception } from '@poppinss/utils';
|
|
2
|
-
export class
|
|
3
|
-
static status = 500;
|
|
4
|
-
static code = 'E_INVALID_ENV_VARIABLES';
|
|
2
|
+
export const E_INVALID_ENV_VARIABLES = class EnvValidationException extends Exception {
|
|
5
3
|
static message = 'Validation failed for one or more environment variables';
|
|
6
|
-
|
|
4
|
+
static code = 'E_INVALID_ENV_VARIABLES';
|
|
5
|
+
help = '';
|
|
6
|
+
};
|
package/build/src/validator.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E_INVALID_ENV_VARIABLES } from './exceptions.js';
|
|
2
2
|
export class EnvValidator {
|
|
3
3
|
#schema;
|
|
4
4
|
#error;
|
|
5
5
|
constructor(schema) {
|
|
6
6
|
this.#schema = schema;
|
|
7
|
-
this.#error = new
|
|
7
|
+
this.#error = new E_INVALID_ENV_VARIABLES();
|
|
8
8
|
}
|
|
9
9
|
validate(values) {
|
|
10
|
-
const
|
|
10
|
+
const help = [];
|
|
11
11
|
const validated = Object.keys(this.#schema).reduce((result, key) => {
|
|
12
12
|
const value = process.env[key] || values[key];
|
|
13
13
|
try {
|
|
14
14
|
result[key] = this.#schema[key](key, value);
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
|
-
|
|
17
|
+
help.push(`- ${error.message}`);
|
|
18
18
|
}
|
|
19
19
|
return result;
|
|
20
20
|
}, { ...values });
|
|
21
|
-
if (
|
|
22
|
-
this.#error.
|
|
21
|
+
if (help.length) {
|
|
22
|
+
this.#error.help = help.join('\n');
|
|
23
23
|
throw this.#error;
|
|
24
24
|
}
|
|
25
25
|
return validated;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/env",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.5-0",
|
|
4
4
|
"description": "Environment variable manager for Node.js",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@japa/runner": "^2.2.2",
|
|
42
42
|
"@japa/spec-reporter": "^1.3.2",
|
|
43
43
|
"@poppinss/dev-utils": "^2.0.3",
|
|
44
|
-
"@swc/core": "^1.3.
|
|
44
|
+
"@swc/core": "^1.3.32",
|
|
45
45
|
"@types/fs-extra": "^11.0.1",
|
|
46
46
|
"@types/node": "^18.11.18",
|
|
47
47
|
"c8": "^7.12.0",
|
|
48
48
|
"cross-env": "^7.0.3",
|
|
49
49
|
"del-cli": "^5.0.0",
|
|
50
|
-
"eslint": "^8.
|
|
50
|
+
"eslint": "^8.33.0",
|
|
51
51
|
"eslint-config-prettier": "^8.6.0",
|
|
52
52
|
"eslint-plugin-adonis": "^3.0.3",
|
|
53
53
|
"eslint-plugin-prettier": "^4.2.1",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"np": "^7.6.3",
|
|
58
58
|
"prettier": "^2.8.3",
|
|
59
59
|
"ts-node": "^10.9.1",
|
|
60
|
-
"typescript": "^4.9.
|
|
60
|
+
"typescript": "^4.9.5"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@poppinss/utils": "^6.
|
|
63
|
+
"@poppinss/utils": "^6.5.0-0",
|
|
64
64
|
"@poppinss/validator-lite": "^1.0.2",
|
|
65
65
|
"dotenv": "^16.0.3"
|
|
66
66
|
},
|