Browse Source

chore: add script to run redoc

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5222/head
Pranav C 2 years ago
parent
commit
45c1c924d7
  1. 3
      packages/nocodb/package.json
  2. 45
      packages/nocodb/src/run/redoc.ts

3
packages/nocodb/package.json

@ -43,7 +43,8 @@
"watch:run:pg": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG --log-error --project tsconfig.json\"", "watch:run:pg": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG --log-error --project tsconfig.json\"",
"run": "ts-node src/run/docker", "run": "ts-node src/run/docker",
"watch:try": "nodemon -e ts,js -w ./src -x \"ts-node src/run/try --log-error --project tsconfig.json\"", "watch:try": "nodemon -e ts,js -w ./src -x \"ts-node src/run/try --log-error --project tsconfig.json\"",
"example:docker": "ts-node src/run/docker.ts" "example:docker": "ts-node src/run/docker.ts",
"redoc": "nodemon -e ts,json -w ./src/schema -x \"ts-node src/run/redoc --log-error --project tsconfig.json\""
}, },
"engines": { "engines": {
"node": ">=8.9" "node": ">=8.9"

45
packages/nocodb/src/run/redoc.ts

@ -0,0 +1,45 @@
import express from 'express';
import path from 'path';
const pageContent = `<!DOCTYPE html>
<html>
<head>
<title>NocoDB API Documentation</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>
<img src="https://static.scarf.sh/a.png?x-pxid=c12a77cc-855e-4602-8a0f-614b2d0da56a"/>
<redoc spec-url='./swagger.json'></redoc>
<script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"></script>
</script>
</body>
</html>`;
const app = express();
app.get('/', function (_req, res) {
res.send(pageContent);
});
app.use(
'/swagger.json',
express.static(path.join(__dirname, '../schema/swagger.json'))
);
app.listen(3001, function () {
console.log(
'Example app listening on port 3001! Go to http://localhost:3001'
);
});
Loading…
Cancel
Save