Node.js based forum software built for the modern web
feat: local redoc view on development mode only
Julian Lam1136a369f3ba
diff --git a/public/vendor/redoc/index.html b/public/vendor/redoc/index.htmlnew file mode 100644index 0000000000..342866d600--- /dev/null+++ b/public/vendor/redoc/index.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<html>+ <head>+ <title>ReDoc</title>+ <!-- needed for adaptive design -->+ <meta charset="utf-8"/>+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">++ <!--+ ReDoc doesn't change outer page styles+ -->+ <style>+ body {+ margin: 0;+ padding: 0;+ }+ </style>+ </head>+ <body>+ <redoc spec-url="apiUrl"></redoc>+ <script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>+ </body>+</html>\ No newline at end of filediff --git a/src/routes/debug.js b/src/routes/debug.jsindex 460534fcdc..b55c1f2440 100644--- a/src/routes/debug.js+++ b/src/routes/debug.js@@ -3,6 +3,9 @@var express = require('express');var nconf = require('nconf');+const fs = require('fs').promises;+const path = require('path');+module.exports = function (app) {var router = express.Router();@@ -10,5 +13,17 @@ module.exports = function (app) {res.redirect(404);});+ // Redoc+ router.get('/spec/read', async (req, res) => {+ const handle = await fs.open(path.resolve(__dirname, '../../public/vendor/redoc/index.html'), 'r');+ let html = await handle.readFile({+ encoding: 'utf-8',+ });+ await handle.close();++ html = html.replace('apiUrl', nconf.get('relative_path') + '/assets/openapi/read.yaml');+ res.status(200).type('text/html').send(html);+ });+app.use(nconf.get('relative_path') + '/debug', router);};