diff --git a/config/dist/commonSchema.js b/config/dist/commonSchema.js deleted file mode 100644 index a3325d001..000000000 --- a/config/dist/commonSchema.js +++ /dev/null @@ -1,197 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.PRODUCTION = exports.DEBUG = exports.NODE_ENV = exports.BUILD_COMMIT_SHORT = exports.BUILD_COMMIT = exports.APP_VERSION = exports.DB_DATABASE = exports.DB_PASSWORD = exports.DB_USER = exports.DB_PORT = exports.DB_HOST = exports.TYPEORM_LOGGING_RELATIVE_PATH = exports.LOGIN_SERVER_KEY = exports.LOGIN_APP_SECRET = exports.LOG4JS_CONFIG = exports.LOG_LEVEL = exports.HUMHUB_ACTIVE = exports.GDT_API_URL = exports.GDT_ACTIVE = exports.GMS_ACTIVE = exports.GRAPHIQL = exports.COMMUNITY_LOCATION = exports.COMMUNITY_SUPPORT_MAIL = exports.COMMUNITY_DESCRIPTION = exports.COMMUNITY_NAME = exports.GRAPHQL_URI = exports.COMMUNITY_URL = exports.DB_VERSION = exports.DECAY_START_TIME = exports.browserUrls = void 0; -const joi_1 = __importDefault(require("joi")); -exports.browserUrls = joi_1.default.array() - .items(joi_1.default.string().uri()) - .custom((value, helpers) => { - const protocol = new URL(value[0]).protocol; - for (const url of value) { - if (new URL(url).protocol !== protocol) { - return helpers.error('any.invalid'); - } - } - return value; -}) - .required() - .description('All URLs need to have same protocol to prevent mixed block errors'); -exports.DECAY_START_TIME = joi_1.default.date() - .iso() // ISO 8601 format for date validation - .description('The start time for decay, expected in ISO 8601 format (e.g. 2021-05-13T17:46:31Z)') - .default(new Date('2021-05-13T17:46:31Z')) // default to the specified date if not provided - .required(); -exports.DB_VERSION = joi_1.default.string() - .pattern(/^\d{4}-[a-z0-9-_]+$/) - .message('DB_VERSION must be in the format: YYYY-description, e.g. "0087-add_index_on_user_roles".') - .description('db version string, last migration file name without ending or last folder in entity') - .required(); -exports.COMMUNITY_URL = joi_1.default.string() - .uri({ scheme: ['http', 'https'] }) - .custom((value, helpers) => { - if (value.endsWith('/')) { - return helpers.error('any.invalid', { message: 'URL should not end with a slash (/)' }); - } - return value; -}) - .description('The base URL of the community, should have the same protocol as frontend, admin and backend api to prevent mixed contend issues.') - .default('http://0.0.0.0') - .required(); -exports.GRAPHQL_URI = joi_1.default.string() - .uri({ scheme: ['http', 'https'] }) - .description(` - The external URL of the backend service, - accessible from outside the server (e.g., via Nginx or the server's public URL), - should have the same protocol as frontend and admin to prevent mixed contend issues. - `) - .default('http://0.0.0.0/graphql') - .required(); -exports.COMMUNITY_NAME = joi_1.default.string() - .min(3) - .max(100) - .description('The name of the community') - .default('Gradido Entwicklung') - .required(); -exports.COMMUNITY_DESCRIPTION = joi_1.default.string() - .min(10) - .max(300) - .description('A short description of the community') - .default('Die lokale Entwicklungsumgebung von Gradido.') - .required(); -exports.COMMUNITY_SUPPORT_MAIL = joi_1.default.string() - .email() - .description('The support email address for the community will be used in frontend and E-Mails') - .default('support@supportmail.com') - .required(); -exports.COMMUNITY_LOCATION = joi_1.default.string() - .pattern(/^[-+]?[0-9]{1,2}(\.[0-9]+)?,\s?[-+]?[0-9]{1,3}(\.[0-9]+)?$/) - .when('GMS_ACTIVE', { - is: true, - then: joi_1.default.string().required(), - otherwise: joi_1.default.string().optional() -}) - .description('Geographical location of the community in "latitude, longitude" format') - .default('49.280377, 9.690151'); -exports.GRAPHIQL = joi_1.default.boolean() - .description('Flag for enabling GraphQL playground for debugging.') - .default(false) - .when('NODE_ENV', { - is: 'development', - then: joi_1.default.boolean().valid(true, false).required(), // only allow true in development mode - otherwise: joi_1.default.boolean().valid(false).required() // false in any other mode -}); -exports.GMS_ACTIVE = joi_1.default.boolean() - .description('Flag to indicate if the GMS (Geographic Member Search) service is used.') - .default(false) - .required(); -exports.GDT_ACTIVE = joi_1.default.boolean() - .description('Flag to indicate if the GMS (Geographic Member Search) service is used.') - .default(false) - .required(); -exports.GDT_API_URL = joi_1.default.string() - .uri({ scheme: ['http', 'https'] }) - .default('https://gdt.gradido.net') - .when('GDT_ACTIVE', { is: true, then: joi_1.default.required() }) - .description('The URL for GDT API endpoint'); -exports.HUMHUB_ACTIVE = joi_1.default.boolean() - .description('Flag to indicate if the HumHub based Community Server is used.') - .default(false) - .required(); -exports.LOG_LEVEL = joi_1.default.string() - .valid('all', 'mark', 'trace', 'debug', 'info', 'warn', 'error', 'fatal', 'off') - .description('set log level') - .default('info') - .required(); -exports.LOG4JS_CONFIG = joi_1.default.string() - .pattern(/^[a-zA-Z0-9-_]+\.json$/) - .message('LOG4JS_CONFIG must be a valid filename ending with .json') - .description('config file name for log4js config file') - .default('log4js-config.json') - .required(); -exports.LOGIN_APP_SECRET = joi_1.default.string() - .pattern(/^[a-fA-F0-9]+$/) - .message('need to be valid hex') - .default('21ffbbc616fe') - .description('App secret for salt component for libsodium crypto_pwhash') - .required(); -exports.LOGIN_SERVER_KEY = joi_1.default.string() - .pattern(/^[a-fA-F0-9]+$/) - .length(32) - .message('need to be valid hex and 32 character') - .default('a51ef8ac7ef1abf162fb7a65261acd7a') - .description('Server key for password hashing as additional salt for libsodium crypto_shorthash_keygen') - .required(); -exports.TYPEORM_LOGGING_RELATIVE_PATH = joi_1.default.string() - .pattern(/^[a-zA-Z0-9-_\.]+\.log$/) - .message('TYPEORM_LOGGING_RELATIVE_PATH must be a valid filename ending with .log') - .description('log file name for logging typeorm activities') - .default('typeorm.log') - .required(); -exports.DB_HOST = joi_1.default.string() - .hostname() - .message('must be a valid host with alphanumeric characters, numbers, points and -') - .description("database host like 'localhost' or 'mariadb' in docker setup") - .default('localhost') - .required(); -exports.DB_PORT = joi_1.default.number() - .integer() - .min(1024) - .max(49151) - .description('database port, default: 3306') - .default(3306) - .required(); -exports.DB_USER = joi_1.default.string() - .pattern(/^[A-Za-z0-9]([A-Za-z0-9-_\.]*[A-Za-z0-9])?$/) // Validates MariaDB username rules - .min(1) // Minimum length 1 - .max(16) // Maximum length 16 - .message('Valid database username (letters, numbers, hyphens, underscores, dots allowed; no spaces, must not start or end with hyphen, dot, or underscore)') - .description('database username for mariadb') - .default('root') - .required(); -exports.DB_PASSWORD = joi_1.default.string() - .when(joi_1.default.ref('NODE_ENV'), { - is: 'development', - then: joi_1.default.string().allow(''), - otherwise: joi_1.default.string() - .min(8) - .max(32) - .pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*(),.?":{}|<>]).+$/) - .message('Password must be between 8 and 32 characters long, and contain at least one uppercase letter, one lowercase letter, one number, and one special character (e.g., !@#$%^&*).') -}) - .description('Password for the database user. In development mode, an empty password is allowed. In other environments, a complex password is required.') - .default('') - .required(); -exports.DB_DATABASE = joi_1.default.string() - .pattern(/^[a-zA-Z][a-zA-Z0-9_-]{1,63}$/) - .description('Database name like gradido_community (must start with a letter, and can only contain letters, numbers, underscores, or dashes)') - .default('gradido_community') - .required(); -exports.APP_VERSION = joi_1.default.string() - .pattern(/^\d+\.\d+\.\d+$/) - .message('Version must be in the format "major.minor.patch" (e.g., "2.4.1")') - .description('App Version from package.json, alle modules share one version') - .required(); -exports.BUILD_COMMIT = joi_1.default.string() - .pattern(/^[0-9a-f]{40}$/) - .message('The commit hash must be a 40-character hexadecimal string.') - .description('The full git commit hash.') - .optional(); -exports.BUILD_COMMIT_SHORT = joi_1.default.string() - .pattern(/^[0-9a-f]{7}$/) - .message('The first 7 hexadecimal character from git commit hash.') - .description('A short version from the git commit hash.') - .required(); -exports.NODE_ENV = joi_1.default.string() - .valid('production', 'development', 'test') - .default('development') - .description('Specifies the environment in which the application is running.'); -exports.DEBUG = joi_1.default.boolean() - .description('Indicates whether the application is in debugging mode. Set to true when NODE_ENV is not "production".') - .default(false) - .required(); -exports.PRODUCTION = joi_1.default.boolean() - .default(false) - .description('Indicates whether the application is running in production mode. Set to true when NODE_ENV is "production".') - .required(); diff --git a/config/dist/index.js b/config/dist/index.js deleted file mode 100644 index 39454919a..000000000 --- a/config/dist/index.js +++ /dev/null @@ -1,43 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.validate = validate; -__exportStar(require("./commonSchema"), exports); -function validate(schema, data) { - const { error } = schema.validate(data); - const schemaJson = schema.describe(); - if (error) { - error.details.forEach((err) => { - if (!err.context) { - throw new Error('missing context in config validation with joi'); - } - const key = err.context.key; - if (!key) { - throw new Error('missing key in config validation with joi'); - } - const value = err.context.value; - const description = schemaJson.keys[key] - ? schema.describe().keys[key].flags.description - : 'No description available'; - if (data[key] === undefined) { - throw new Error(`Environment Variable '${key}' is missing. ${description}`); - } - else { - throw new Error(`Error on Environment Variable ${key} with value = ${value}: ${err.message}. ${description}`); - } - }); - } -} diff --git a/config/dist/types/commonSchema.d.ts b/config/dist/types/commonSchema.d.ts deleted file mode 100644 index 3d5892030..000000000 --- a/config/dist/types/commonSchema.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import Joi from 'joi'; -export declare const browserUrls: Joi.ArraySchema; -export declare const DECAY_START_TIME: Joi.DateSchema; -export declare const DB_VERSION: Joi.StringSchema; -export declare const COMMUNITY_URL: Joi.StringSchema; -export declare const GRAPHQL_URI: Joi.StringSchema; -export declare const COMMUNITY_NAME: Joi.StringSchema; -export declare const COMMUNITY_DESCRIPTION: Joi.StringSchema; -export declare const COMMUNITY_SUPPORT_MAIL: Joi.StringSchema; -export declare const COMMUNITY_LOCATION: Joi.StringSchema; -export declare const GRAPHIQL: Joi.BooleanSchema; -export declare const GMS_ACTIVE: Joi.BooleanSchema; -export declare const GDT_ACTIVE: Joi.BooleanSchema; -export declare const GDT_API_URL: Joi.StringSchema; -export declare const HUMHUB_ACTIVE: Joi.BooleanSchema; -export declare const LOG_LEVEL: Joi.StringSchema; -export declare const LOG4JS_CONFIG: Joi.StringSchema; -export declare const LOGIN_APP_SECRET: Joi.StringSchema; -export declare const LOGIN_SERVER_KEY: Joi.StringSchema; -export declare const TYPEORM_LOGGING_RELATIVE_PATH: Joi.StringSchema; -export declare const DB_HOST: Joi.StringSchema; -export declare const DB_PORT: Joi.NumberSchema; -export declare const DB_USER: Joi.StringSchema; -export declare const DB_PASSWORD: Joi.StringSchema; -export declare const DB_DATABASE: Joi.StringSchema; -export declare const APP_VERSION: Joi.StringSchema; -export declare const BUILD_COMMIT: Joi.StringSchema; -export declare const BUILD_COMMIT_SHORT: Joi.StringSchema; -export declare const NODE_ENV: Joi.StringSchema; -export declare const DEBUG: Joi.BooleanSchema; -export declare const PRODUCTION: Joi.BooleanSchema; diff --git a/config/dist/types/index.d.ts b/config/dist/types/index.d.ts deleted file mode 100644 index 43b8e8429..000000000 --- a/config/dist/types/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { ObjectSchema } from 'joi'; -export * from './commonSchema'; -export declare function validate(schema: ObjectSchema, data: any): void; diff --git a/config/package.json b/config/package.json index bda5abeae..711041d86 100644 --- a/config/package.json +++ b/config/package.json @@ -2,8 +2,8 @@ "name": "gradido-config", "version": "1.0.0", "description": "Gradido Config for validate config", - "main": "dist/index.js", - "types": "dist/types", + "main": "build/index.js", + "types": "build/types", "type": "commonjs", "repository": "https://github.com/gradido/gradido/config", "author": "einhornimmond", @@ -11,7 +11,7 @@ "private": false, "scripts": { "build": "tsc", - "clean": "rm -rf dist", + "clean": "rm -rf build", "prepare": "npm run clean && npm run build", "test": "node test/index" }, diff --git a/config/tsconfig.json b/config/tsconfig.json index a741839b3..1b538cffb 100644 --- a/config/tsconfig.json +++ b/config/tsconfig.json @@ -1,13 +1,13 @@ { "compilerOptions": { - "outDir": "dist", + "outDir": "build", "module": "CommonJS", "target": "ES6", "declaration": true, // Generate type definitions - "declarationDir": "dist/types", // Storage location for .d.ts files + "declarationDir": "build/types", // Storage location for .d.ts files "strict": true, "esModuleInterop": true, // Enables Interop with CommonJS }, "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] + "exclude": ["node_modules", "build"] } \ No newline at end of file