@men-mvc/config
Advanced tools
Comparing version 0.64.0 to 0.65.0
@@ -9,3 +9,4 @@ import { BaseConfig } from './types'; | ||
private hasValidFileSystemDriver; | ||
private validateS3FileSystemConfig; | ||
validate: () => void; | ||
} |
@@ -5,2 +5,3 @@ "use strict"; | ||
const types_1 = require("./types"); | ||
const utilities_1 = require("./utilities"); | ||
class ConfigValidator { | ||
@@ -42,4 +43,12 @@ config; | ||
.some((driver) => driver.toLowerCase() === | ||
this.config.fileSystem.storageDriver?.toLowerCase()); | ||
this.config.fileSystem.storageDriver?.toString().toLowerCase()); | ||
}; | ||
// TODO: finish | ||
// checking if the driver is s3 is already done before calling this function | ||
validateS3FileSystemConfig = () => { | ||
if (!this.config.fileSystem?.s3) { | ||
throw new Error(`AWS credentials are not set for s3 filesystem driver.`); | ||
} | ||
return true; | ||
}; | ||
validate = () => { | ||
@@ -60,4 +69,13 @@ if (!this.hasValidMailDriver()) { | ||
*/ | ||
if (!this.hasValidFileSystemDriver()) { | ||
// TODO: in the future, when more driver is added, add validation rule that test supports only local driver. | ||
if (this.hasValidFileSystemDriver()) { | ||
// if this.config.fileSystem?.storageDriver is undefined is already checked by hasValidFileSystemDriver funciton | ||
if ((0, utilities_1.isTestEnvironment)() && | ||
this.config.fileSystem?.storageDriver !== types_1.FileSystemDriver.local) { | ||
throw new Error(`Tests only support local filesystem driver.`); | ||
} | ||
if (this.config.fileSystem?.storageDriver === types_1.FileSystemDriver.s3) { | ||
// TODO: validate the S3 credentials | ||
} | ||
} | ||
else { | ||
throw new Error(`Invalid file system storage driver.`); | ||
@@ -64,0 +82,0 @@ } |
import { CacheDriver } from './cacheDriver'; | ||
import { MailConfig } from './mailConfig'; | ||
import { FileSystemDriver } from './fileSystemDriver'; | ||
import { S3Config } from './s3Config'; | ||
export interface BaseConfig { | ||
@@ -30,2 +31,3 @@ app: { | ||
maxUploadLimit: number; | ||
s3?: S3Config; | ||
}; | ||
@@ -32,0 +34,0 @@ logging?: { |
export declare enum FileSystemDriver { | ||
local = "local" | ||
local = "local", | ||
s3 = "s3" | ||
} |
@@ -7,3 +7,4 @@ "use strict"; | ||
(function (FileSystemDriver) { | ||
FileSystemDriver["local"] = "local"; // TODO: add more driver in the future | ||
FileSystemDriver["local"] = "local"; | ||
FileSystemDriver["s3"] = "s3"; | ||
})(FileSystemDriver = exports.FileSystemDriver || (exports.FileSystemDriver = {})); |
@@ -9,1 +9,2 @@ export * from './baseConfig'; | ||
export * from './envVarDeclaration'; | ||
export * from './baseConfig'; |
@@ -25,1 +25,2 @@ "use strict"; | ||
__exportStar(require("./envVarDeclaration"), exports); | ||
__exportStar(require("./baseConfig"), exports); |
@@ -6,5 +6,5 @@ import { EnvVarDeclaration } from './types/envVarDeclaration'; | ||
export declare const setEnvVariable: (key: string, value: string) => void; | ||
export declare const isTestEnvironment: () => boolean; | ||
/** | ||
* the functions inside this file are available within the core package only | ||
* TODO: rename this to is running framework tests | ||
*/ | ||
@@ -11,0 +11,0 @@ export declare const isRunningFrameworkTests: () => boolean; |
@@ -6,6 +6,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getAppProjectConfigDirectory = exports.getConfigKeyEnvVarNameMappings = exports.getConfigKeyList = exports.isRunningFrameworkTests = exports.setEnvVariable = exports.getEnvVariable = exports.getEnvVariables = exports.getAppEnv = void 0; | ||
exports.getAppProjectConfigDirectory = exports.getConfigKeyEnvVarNameMappings = exports.getConfigKeyList = exports.isRunningFrameworkTests = exports.isTestEnvironment = exports.setEnvVariable = exports.getEnvVariable = exports.getEnvVariables = exports.getAppEnv = void 0; | ||
const findup_sync_1 = __importDefault(require("findup-sync")); | ||
const globals_1 = require("./globals"); | ||
const envVarDeclaration_1 = require("./types/envVarDeclaration"); | ||
// TODO: write tests for the utility functions inside this file | ||
const getAppEnv = () => (0, exports.getEnvVariable)(`NODE_ENV`, `local`); | ||
@@ -34,5 +35,6 @@ exports.getAppEnv = getAppEnv; | ||
exports.setEnvVariable = setEnvVariable; | ||
const isTestEnvironment = () => (0, exports.getAppEnv)() === 'test'; | ||
exports.isTestEnvironment = isTestEnvironment; | ||
/** | ||
* the functions inside this file are available within the core package only | ||
* TODO: rename this to is running framework tests | ||
*/ | ||
@@ -39,0 +41,0 @@ const isRunningFrameworkTests = () => process.env.CORE_TEST ? true : false; |
{ | ||
"name": "@men-mvc/config", | ||
"version": "0.64.0", | ||
"version": "0.65.0", | ||
"description": "Config package for Men MVC framework.", | ||
@@ -49,3 +49,3 @@ "private": false, | ||
"license": "MIT", | ||
"gitHead": "2bcfe87b5f2d9828da0d6608a9694a582576ec23" | ||
"gitHead": "e722f8a80f5007c7029ffa7dc148941faf7af15e" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29269
39
707