Return errors when rule parsing is bad
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b220c223ef
commit
4a0cb3475e
@ -157,7 +157,7 @@ export class Database {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setRules(rawRules: string) {
|
async setRules(rawRules: string): Promise<RuleError | undefined> {
|
||||||
const { runner, error } = compileRule(rawRules);
|
const { runner, error } = compileRule(rawRules);
|
||||||
if (error) return error;
|
if (error) return error;
|
||||||
await Settings.setDatabaseRules(this.name, rawRules);
|
await Settings.setDatabaseRules(this.name, rawRules);
|
||||||
|
@ -112,7 +112,14 @@ AdminRoute.get("/database", (ctx) => {
|
|||||||
|
|
||||||
if (publickey) await db.setPublicKey(publickey);
|
if (publickey) await db.setPublicKey(publickey);
|
||||||
|
|
||||||
if (rules) await db.setRules(rules);
|
if (rules) {
|
||||||
|
const error = await db.setRules(rules);
|
||||||
|
if (error) {
|
||||||
|
ctx.status = 500;
|
||||||
|
ctx.body = error;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (accesskey) await db.setAccessKey(accesskey);
|
if (accesskey) await db.setAccessKey(accesskey);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user