@sync-in/server
Version:
The secure, open-source platform for file storage, sharing, collaboration, and sync
177 lines (176 loc) • 7.67 kB
JavaScript
/*
* Copyright (C) 2012-2025 Johan Legrand <johan.legrand@sync-in.com>
* This file is part of Sync-in | The open source file sync and share solution
* See the LICENSE file for licensing details
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: Object.getOwnPropertyDescriptor(all, name).get
});
}
_export(exports, {
get GlobalConfig () {
return GlobalConfig;
},
get LoggerConfig () {
return LoggerConfig;
},
get ServerConfig () {
return ServerConfig;
}
});
const _classtransformer = require("class-transformer");
const _classvalidator = require("class-validator");
const _nodeos = require("node:os");
const _applicationsconfig = require("../applications/applications.config");
const _authconfig = require("../authentication/auth.config");
const _cacheconfig = require("../infrastructure/cache/cache.config");
const _databaseconfig = require("../infrastructure/database/database.config");
const _mailerconfig = require("../infrastructure/mailer/mailer.config");
const _websocketconfig = require("../infrastructure/websocket/web-socket.config");
const _configconstants = require("./config.constants");
function _ts_decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function _ts_metadata(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
let ServerConfig = class ServerConfig {
constructor(){
this.host = '0.0.0.0';
this.port = 8080;
this.workers = 1;
this.trustProxy = 1;
this.restartOnFailure = true;
}
};
_ts_decorate([
(0, _classvalidator.IsIP)(),
_ts_metadata("design:type", String)
], ServerConfig.prototype, "host", void 0);
_ts_decorate([
(0, _classvalidator.IsInt)(),
(0, _classvalidator.Min)(1024),
(0, _classvalidator.Max)(65535),
_ts_metadata("design:type", Number)
], ServerConfig.prototype, "port", void 0);
_ts_decorate([
(0, _classtransformer.Transform)(({ value })=>value === 0 || value === 'auto' ? (0, _nodeos.cpus)().length : Math.max(Number(value), 1)),
(0, _classvalidator.IsInt)(),
(0, _classvalidator.Min)(1),
_ts_metadata("design:type", Number)
], ServerConfig.prototype, "workers", void 0);
_ts_decorate([
(0, _classvalidator.IsOptional)(),
_ts_metadata("design:type", Object)
], ServerConfig.prototype, "trustProxy", void 0);
_ts_decorate([
(0, _classvalidator.IsBoolean)(),
_ts_metadata("design:type", Boolean)
], ServerConfig.prototype, "restartOnFailure", void 0);
let LoggerConfig = class LoggerConfig {
constructor(){
this.level = 'info';
this.stdout = true;
this.colorize = true;
this.filePath = _configconstants.DEFAULT_LOG_FILE_PATH;
}
};
_ts_decorate([
(0, _classvalidator.IsString)(),
(0, _classvalidator.IsNotEmpty)(),
_ts_metadata("design:type", typeof Level === "undefined" ? Object : Level)
], LoggerConfig.prototype, "level", void 0);
_ts_decorate([
(0, _classvalidator.IsBoolean)(),
_ts_metadata("design:type", Boolean)
], LoggerConfig.prototype, "stdout", void 0);
_ts_decorate([
(0, _classvalidator.IsBoolean)(),
_ts_metadata("design:type", Boolean)
], LoggerConfig.prototype, "colorize", void 0);
_ts_decorate([
(0, _classvalidator.IsOptional)(),
(0, _classvalidator.IsString)(),
(0, _classtransformer.Transform)(({ value })=>value || _configconstants.DEFAULT_LOG_FILE_PATH),
_ts_metadata("design:type", String)
], LoggerConfig.prototype, "filePath", void 0);
let GlobalConfig = class GlobalConfig {
constructor(){
this.server = new ServerConfig();
this.logger = new LoggerConfig();
this.cache = new _cacheconfig.CacheConfig();
this.websocket = new _websocketconfig.WebSocketConfig();
}
};
_ts_decorate([
(0, _classvalidator.IsDefined)(),
(0, _classvalidator.IsObject)(),
(0, _classvalidator.IsNotEmptyObject)(),
(0, _classvalidator.ValidateNested)(),
(0, _classtransformer.Type)(()=>ServerConfig),
_ts_metadata("design:type", typeof ServerConfig === "undefined" ? Object : ServerConfig)
], GlobalConfig.prototype, "server", void 0);
_ts_decorate([
(0, _classvalidator.IsDefined)(),
(0, _classvalidator.IsObject)(),
(0, _classvalidator.IsNotEmptyObject)(),
(0, _classvalidator.ValidateNested)(),
(0, _classtransformer.Type)(()=>LoggerConfig),
_ts_metadata("design:type", typeof LoggerConfig === "undefined" ? Object : LoggerConfig)
], GlobalConfig.prototype, "logger", void 0);
_ts_decorate([
(0, _classvalidator.IsDefined)(),
(0, _classvalidator.IsObject)(),
(0, _classvalidator.IsNotEmptyObject)(),
(0, _classvalidator.ValidateNested)(),
(0, _classtransformer.Type)(()=>_databaseconfig.MySQLConfig),
_ts_metadata("design:type", typeof _databaseconfig.MySQLConfig === "undefined" ? Object : _databaseconfig.MySQLConfig)
], GlobalConfig.prototype, "mysql", void 0);
_ts_decorate([
(0, _classvalidator.IsDefined)(),
(0, _classvalidator.IsObject)(),
(0, _classvalidator.IsNotEmptyObject)(),
(0, _classvalidator.ValidateNested)(),
(0, _classtransformer.Type)(()=>_cacheconfig.CacheConfig),
_ts_metadata("design:type", typeof _cacheconfig.CacheConfig === "undefined" ? Object : _cacheconfig.CacheConfig)
], GlobalConfig.prototype, "cache", void 0);
_ts_decorate([
(0, _classvalidator.IsOptional)(),
(0, _classvalidator.IsObject)(),
(0, _classvalidator.IsNotEmptyObject)(),
(0, _classvalidator.ValidateNested)(),
(0, _classtransformer.Type)(()=>_websocketconfig.WebSocketConfig),
_ts_metadata("design:type", typeof _websocketconfig.WebSocketConfig === "undefined" ? Object : _websocketconfig.WebSocketConfig)
], GlobalConfig.prototype, "websocket", void 0);
_ts_decorate([
(0, _classvalidator.IsDefined)(),
(0, _classvalidator.IsObject)(),
(0, _classvalidator.IsNotEmptyObject)(),
(0, _classvalidator.ValidateNested)(),
(0, _classtransformer.Type)(()=>_authconfig.AuthConfig),
_ts_metadata("design:type", typeof _authconfig.AuthConfig === "undefined" ? Object : _authconfig.AuthConfig)
], GlobalConfig.prototype, "auth", void 0);
_ts_decorate([
(0, _classvalidator.IsOptional)(),
(0, _classvalidator.IsObject)(),
(0, _classvalidator.ValidateNested)(),
(0, _classtransformer.Type)(()=>_mailerconfig.MailerConfig),
_ts_metadata("design:type", typeof _mailerconfig.MailerConfig === "undefined" ? Object : _mailerconfig.MailerConfig)
], GlobalConfig.prototype, "mail", void 0);
_ts_decorate([
(0, _classvalidator.IsDefined)(),
(0, _classvalidator.IsObject)(),
(0, _classvalidator.IsNotEmptyObject)(),
(0, _classvalidator.ValidateNested)(),
(0, _classtransformer.Type)(()=>_applicationsconfig.ApplicationsConfig),
_ts_metadata("design:type", typeof _applicationsconfig.ApplicationsConfig === "undefined" ? Object : _applicationsconfig.ApplicationsConfig)
], GlobalConfig.prototype, "applications", void 0);
//# sourceMappingURL=config.validation.js.map