First basic version
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user