Updates
This commit is contained in:
+10
-5
@@ -22,7 +22,7 @@ const put_result_1 = __importDefault(require("./functions/put-result"));
|
||||
const delete_result_1 = __importDefault(require("./functions/delete-result"));
|
||||
function apiCrudHandler(params) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a, _b;
|
||||
var _a, _b, _c;
|
||||
try {
|
||||
const { auth, method } = params;
|
||||
const isAuthorized = yield (auth === null || auth === void 0 ? void 0 : auth());
|
||||
@@ -72,15 +72,20 @@ function apiCrudHandler(params) {
|
||||
};
|
||||
}
|
||||
}
|
||||
let result;
|
||||
switch (method) {
|
||||
case "GET":
|
||||
return yield (0, get_result_1.default)(crudParams);
|
||||
result = yield (0, get_result_1.default)(crudParams);
|
||||
case "POST":
|
||||
return yield (0, post_result_1.default)(crudParams);
|
||||
result = yield (0, post_result_1.default)(crudParams);
|
||||
case "PUT":
|
||||
return yield (0, put_result_1.default)(crudParams);
|
||||
result = yield (0, put_result_1.default)(crudParams);
|
||||
case "DELETE":
|
||||
return yield (0, delete_result_1.default)(crudParams);
|
||||
result = yield (0, delete_result_1.default)(crudParams);
|
||||
}
|
||||
yield ((_c = params.postResultsFn) === null || _c === void 0 ? void 0 : _c.call(params, Object.assign(Object.assign({}, crudParams), { res: result })));
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
return {
|
||||
success: false,
|
||||
|
||||
+2
-2
@@ -130,8 +130,8 @@ function createDbFromSchema(_a) {
|
||||
* @description Update table if table exists
|
||||
*/
|
||||
const updateExistingTable = yield (0, updateTable_1.default)({
|
||||
dbFullName: dbFullName,
|
||||
tableName: tableName,
|
||||
dbFullName,
|
||||
tableName,
|
||||
tableFields: fields,
|
||||
userId,
|
||||
dbSchema: database,
|
||||
|
||||
Vendored
+12
@@ -2216,6 +2216,7 @@ export type APIPathsParams<T extends {
|
||||
postMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||
putMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||
deleteMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||
postResultsFn?: APIPathsPostResulstsFn<T>;
|
||||
/** Runs For `POST`, `PUT`, and `DELETE` */
|
||||
crudMiddleware?: APIPathsParamsCrudMiddleware<T>;
|
||||
method: "GET" | "POST" | "PUT" | "DELETE";
|
||||
@@ -2264,6 +2265,17 @@ export type APIPathsParamsCrudMiddleware<T extends {
|
||||
table: K;
|
||||
targetId?: number | string;
|
||||
}) => Promise<APIPathsBody<T> | undefined>;
|
||||
export type APIPathsPostResulstsFn<T extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}, K extends string = string> = (params: {
|
||||
body?: APIPathsBody<T>;
|
||||
query?: DsqlCrudQueryObject<T>;
|
||||
table: K;
|
||||
targetId?: number | string;
|
||||
res?: APIResponseObject;
|
||||
}) => Promise<APIPathsBody<T> | undefined>;
|
||||
export type APIPathsParamsAllowedTable = {
|
||||
table: string;
|
||||
allowedFields?: (string | RegExp)[];
|
||||
|
||||
Reference in New Issue
Block a user