Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

✨ Serve schema up at /schema.json

Alicia Sykes269d3c44ba39
diff --git a/services/app.js b/services/app.js
index 508ea17d..edbf9d06 100644
--- a/services/app.js
+++ b/services/app.js
@@ -11,13 +11,16 @@ const crypto = require('crypto');
/* Project root β€” one level up from services/ */
const rootDir = path.join(__dirname, '..');
-/* Import NPM dependencies */
-const yaml = require('./utils/yaml');
-
/* Import Express + middleware functions */
const express = require('express');
const basicAuth = require('express-basic-auth');
+/* Config schema, served at /schema.json for use by external editors */
+const configSchema = require('../src/utils/config/ConfigSchema.json');
+
+/* Import NPM dependencies */
+const yaml = require('./utils/yaml');
+
/* Kick of some basic checks */
require('./utils/update-checker'); // Checks if there are any updates available, prints message
@@ -45,6 +48,7 @@ const ENDPOINTS = {
systemInfo: '/system-info',
corsProxy: '/cors-proxy',
getUser: '/get-user',
+ configSchema: '/schema.json',
api: '/api',
};
@@ -323,6 +327,8 @@ const app = express()
onConfigSaved: (filename, newConf) => { if (filename === 'conf.yml') config = newConf; },
}))
.use(ENDPOINTS.api, apiErrorHandler)
+ // Serves the config schema, for use by external editors and validators
+ .get(ENDPOINTS.configSchema, (req, res) => res.json(configSchema))
// Middleware to serve any .yml/.yaml files in USER_DATA_DIR with optional protection
// Note: returns stripped version if auth configured but not yet authenticated
.get(/\.ya?ml$/i, bootstrapAuth, (req, res) => {
diff --git a/vite.config.mjs b/vite.config.mjs
index 07a706ef..f24ec739 100644
--- a/vite.config.mjs
+++ b/vite.config.mjs
@@ -74,7 +74,7 @@ export default defineConfig({
skipWaiting: false,
navigateFallback: '/index.html',
navigateFallbackDenylist: [
- /^\/(status-check|ping-check|system-info|cors-proxy|get-user|config-manager)\b/,
+ /^\/(status-check|ping-check|system-info|cors-proxy|get-user|config-manager|schema)\b/,
],
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
globIgnores: [