Fixing several bugs and adding very basic rule support
This commit is contained in:
@ -3,13 +3,18 @@ import Settings from "../../settings";
|
||||
import getForm from "../helper/form";
|
||||
import Logging from "@hibas123/nodelogging";
|
||||
import getTable from "../helper/table";
|
||||
import { BadRequestError } from "../helper/errors";
|
||||
import { BadRequestError, NoPermissionError } from "../helper/errors";
|
||||
import { DatabaseManager } from "../../database/database";
|
||||
import { FieldEncoder } from "../../database/query";
|
||||
import getTemplate from "../helper/hb";
|
||||
import config from "../../config";
|
||||
|
||||
const AdminRoute = new Router();
|
||||
|
||||
AdminRoute.use((ctx, next) => {
|
||||
//TODO: Check permission
|
||||
AdminRoute.use(async (ctx, next) => {
|
||||
const { key } = ctx.query;
|
||||
if (key !== config.general.admin)
|
||||
throw new NoPermissionError("No permission!");
|
||||
return next();
|
||||
})
|
||||
|
||||
@ -50,7 +55,7 @@ AdminRoute.get("/data", async ctx => {
|
||||
});
|
||||
let res = [["key", "value"]];
|
||||
stream.on("data", ({ key, value }) => {
|
||||
res.push([key, value]);
|
||||
res.push([key, JSON.stringify(FieldEncoder.decode(value))]);
|
||||
})
|
||||
|
||||
stream.on("error", no);
|
||||
|
Reference in New Issue
Block a user