Fixing several bugs and adding very basic rule support

This commit is contained in:
Fabian
2019-09-19 16:24:35 +02:00
parent 429ba7e291
commit a7f7edcd0b
8 changed files with 163 additions and 73 deletions

View File

@ -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);