Updates
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
// @ts-check
|
||||
|
||||
import _ from "lodash";
|
||||
import serverError from "../../backend/serverError";
|
||||
import runQuery, { DbContextsArray } from "../../backend/db/runQuery";
|
||||
@@ -7,7 +5,6 @@ import {
|
||||
ApiGetQueryObject,
|
||||
DSQL_TableSchemaType,
|
||||
GetReturn,
|
||||
ServerQueryParam,
|
||||
} from "../../../types";
|
||||
import apiGetGrabQueryAndValues from "../../../utils/grab-query-and-values";
|
||||
|
||||
@@ -19,6 +16,7 @@ type Param<T extends { [key: string]: any } = { [key: string]: any }> = {
|
||||
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
|
||||
debug?: boolean;
|
||||
dbContext?: (typeof DbContextsArray)[number];
|
||||
forceLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -34,16 +32,14 @@ export default async function apiGet<
|
||||
dbSchema,
|
||||
debug,
|
||||
dbContext,
|
||||
forceLocal,
|
||||
}: Param<T>): Promise<import("../../../types").GetReturn> {
|
||||
const queryAndValues = apiGetGrabQueryAndValues({
|
||||
query,
|
||||
values: queryValues,
|
||||
});
|
||||
|
||||
if (
|
||||
typeof query == "string" &&
|
||||
query.match(/^alter|^delete|information_schema|databases|^create/i)
|
||||
) {
|
||||
if (typeof query == "string" && query.match(/^alter|^delete|^create/i)) {
|
||||
return { success: false, msg: "Wrong Input." };
|
||||
}
|
||||
|
||||
@@ -59,6 +55,7 @@ export default async function apiGet<
|
||||
tableName,
|
||||
dbContext,
|
||||
debug,
|
||||
forceLocal,
|
||||
});
|
||||
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
|
||||
@@ -10,6 +10,7 @@ type Param = {
|
||||
tableName?: string;
|
||||
dbSchema?: DSQL_DatabaseSchemaType;
|
||||
dbContext?: (typeof DbContextsArray)[number];
|
||||
forceLocal?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -22,6 +23,7 @@ export default async function apiPost({
|
||||
tableName,
|
||||
dbSchema,
|
||||
dbContext,
|
||||
forceLocal,
|
||||
}: Param): Promise<PostReturn> {
|
||||
if (typeof query === "string" && query?.match(/^create |^alter |^drop /i)) {
|
||||
return { success: false, msg: "Wrong Input" };
|
||||
@@ -49,6 +51,7 @@ export default async function apiPost({
|
||||
queryValuesArray: queryValues,
|
||||
tableName,
|
||||
dbContext,
|
||||
forceLocal,
|
||||
});
|
||||
|
||||
results = result;
|
||||
|
||||
Reference in New Issue
Block a user