First basic version

This commit is contained in:
Fabian Stamm
2019-11-04 00:45:30 +01:00
parent a78e98a0c8
commit 68011e3866
10 changed files with 431 additions and 393 deletions

View File

@ -4,8 +4,9 @@ import getForm from "../helper/form";
import getTable from "../helper/table";
import { BadRequestError, NoPermissionError } from "../helper/errors";
import { DatabaseManager } from "../../database/database";
import { FieldEncoder } from "../../database/query";
import { MP } from "../../database/query";
import config from "../../config";
import Logging from "@hibas123/logging";
const AdminRoute = new Router();
@ -46,14 +47,16 @@ AdminRoute.get("/data", async ctx => {
throw new BadRequestError("Database not found");
let res = await new Promise<string[][]>((yes, no) => {
const stream = db.level.createReadStream({
const stream = db.data.createReadStream({
keys: true,
values: true,
valueAsBuffer: true
valueAsBuffer: true,
keyAsBuffer: false
});
let res = [["key", "value"]];
stream.on("data", ({ key, value }) => {
res.push([key, JSON.stringify(FieldEncoder.decode(value))]);
stream.on("data", ({ key, value }: { key: string, value: Buffer }) => {
Logging.debug("Admin Key:", key);
res.push([key, key.split("/").length > 2 ? value.toString() : JSON.stringify(MP.decode(value))]);
})
stream.on("error", no);