near-protocol-rewards
Version:
A transparent, metric-based rewards system for NEAR projects
46 lines (45 loc) • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateConfig = void 0;
const errors_1 = require("../types/errors");
function validateConfig(config) {
const errors = [];
if (!config.githubToken) {
errors.push({
code: errors_1.ErrorCode.INVALID_CONFIG,
message: "githubToken is required",
});
}
if (!config.githubRepo) {
errors.push({
code: errors_1.ErrorCode.INVALID_CONFIG,
message: "githubRepo is required",
});
}
if (config.githubRepo && !config.githubRepo.includes("/")) {
errors.push({
code: errors_1.ErrorCode.INVALID_CONFIG,
message: 'githubRepo must be in format "owner/repo"',
});
}
if (config.storage && config.storage.type === "postgres") {
const { host, port, database, user, password } = config.storage.config;
if (!host || !port || !database || !user || !password) {
errors.push({
code: errors_1.ErrorCode.INVALID_CONFIG,
message: "Invalid postgres configuration",
});
}
}
return {
isValid: errors.length === 0,
errors,
warnings: [],
timestamp: Date.now(),
metadata: {
source: "github",
validationType: "data",
},
};
}
exports.validateConfig = validateConfig;