Adding Dockerfile and build script
This commit is contained in:
@ -42,7 +42,7 @@ const cache = new Map<string, Handlebars.TemplateDelegate>();
|
||||
|
||||
export default function getTemplate(name: string) {
|
||||
let tl: Handlebars.TemplateDelegate;
|
||||
if (!config.general.dev)
|
||||
if (!config.dev)
|
||||
tl = cache.get(name);
|
||||
|
||||
if (!tl) {
|
||||
|
@ -2,9 +2,9 @@ import { LoggingBase } from "@hibas123/nodelogging";
|
||||
import { Context } from "koa";
|
||||
import config from "../../config";
|
||||
|
||||
const route_logging = new LoggingBase({ name: "access", files: { errorfile: null }, console: config.general.dev })
|
||||
const route_logging = new LoggingBase({ name: "access", files: { errorfile: null }, console: config.dev })
|
||||
const RequestLog = async (ctx: Context, next) => {
|
||||
if (!config.general.access_log) return next();
|
||||
if (!config.access_log) return next();
|
||||
let start = process.hrtime()
|
||||
let to = false
|
||||
let print = () => {
|
||||
|
@ -13,7 +13,7 @@ const AdminRoute = new Router();
|
||||
|
||||
AdminRoute.use(async (ctx, next) => {
|
||||
const { key } = ctx.query;
|
||||
if (key !== config.general.admin)
|
||||
if (key !== config.admin)
|
||||
throw new NoPermissionError("No permission!");
|
||||
return next();
|
||||
})
|
||||
@ -87,7 +87,7 @@ AdminRoute
|
||||
}
|
||||
})
|
||||
.post("/database", async ctx => {
|
||||
const { name, rules, publickey, accesskey } = ctx.request.body;
|
||||
const { name, rules, publickey, accesskey, rootkey } = ctx.request.body;
|
||||
|
||||
if (!name)
|
||||
throw new BadRequestError("Name must be set!");
|
||||
@ -101,16 +101,22 @@ AdminRoute
|
||||
|
||||
if (rules)
|
||||
await db.setRules(rules);
|
||||
db
|
||||
|
||||
if (accesskey)
|
||||
await db.setAccessKey(accesskey);
|
||||
|
||||
|
||||
if (rootkey)
|
||||
await db.setRootKey(rootkey);
|
||||
|
||||
|
||||
ctx.body = "Success";
|
||||
})
|
||||
|
||||
AdminRoute.get("/database/new", getForm("/v1/admin/database", "New/Change Database", {
|
||||
name: { label: "Name", type: "text", },
|
||||
accesskey: { label: "Access Key", type: "text" },
|
||||
rootkey: { label: "Root access key", type: "text" },
|
||||
rules: { label: "Rules", type: "textarea", value: `{\n ".write": true, \n ".read": true \n}` },
|
||||
publickey: { label: "Public Key", type: "textarea" }
|
||||
}))
|
||||
|
Reference in New Issue
Block a user