From 46ef63fb9f3c2688118a9d1511293128cfdfe4c9 Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Sun, 10 Jan 2021 02:04:35 +0200 Subject: feat: add dynamic settings page rendering based on the Joi object --- src/api/structures/Setting.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/api/structures') diff --git a/src/api/structures/Setting.js b/src/api/structures/Setting.js index 068ebf1..7b2041d 100644 --- a/src/api/structures/Setting.js +++ b/src/api/structures/Setting.js @@ -9,15 +9,6 @@ const StatsGenerator = require('../utils/StatsGenerator'); // use meta to set custom rendering (render as radio instead of dropdown for example) and custom order // use description to add comments which will show up as a note somewhere next to the option const schema = Joi.object({ - // Server related settings - rateLimitWindow: Joi.number().integer().default(2) - .label('API rate limit window') - .description('Timeframe for which requests are checked/remembered'), - - rateLimitMax: Joi.number().integer().default(5) - .label('API maximum limit') - .description('Max number of connections during windowMs milliseconds before sending a 429 response'), - // Service settings serviceName: Joi.string().default('change-me') .label('Service name') @@ -118,9 +109,18 @@ const schema = Joi.object({ savedStatistics: Joi.array().items(Joi.string().valid(...Object.keys(StatsGenerator.statGenerators)).optional()) .meta({ displayType: 'checkbox' }) .label('Cached statistics') - .description('Which statistics should be saved to the database (refer to Statistics schedule for scheduling). If a statistics is enabled but not set to be saved, it will be generated every time the statistics page is opened') -}); + .description('Which statistics should be saved to the database (refer to Statistics schedule for scheduling).') + .note('If a statistics is enabled but not set to be saved, it will be generated every time the statistics page is opened'), -// schema._ids._byKey.keys() + // Server related settings + rateLimitWindow: Joi.number().integer().default(2) + .label('API rate limit window') + .description('Timeframe for which requests are checked/remembered'), + + rateLimitMax: Joi.number().integer().default(5) + .label('API maximum limit') + .description('Max number of connections during windowMs milliseconds before sending a 429 response') +}); module.exports.schema = schema; +module.exports.configSchema = schema.describe(); -- cgit v1.2.3