Updates
This commit is contained in:
@@ -87,15 +87,23 @@ export default async function apiCrudHandler<
|
||||
}
|
||||
}
|
||||
|
||||
let result: APIResponseObject | undefined;
|
||||
|
||||
switch (method) {
|
||||
case "GET":
|
||||
return await getResult(crudParams);
|
||||
result = await getResult(crudParams);
|
||||
case "POST":
|
||||
return await postResult(crudParams);
|
||||
result = await postResult(crudParams);
|
||||
case "PUT":
|
||||
return await putResult(crudParams);
|
||||
result = await putResult(crudParams);
|
||||
case "DELETE":
|
||||
return await deleteResult(crudParams);
|
||||
result = await deleteResult(crudParams);
|
||||
}
|
||||
|
||||
await params.postResultsFn?.({ ...crudParams, res: result });
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -160,8 +160,8 @@ export default async function createDbFromSchema({
|
||||
* @description Update table if table exists
|
||||
*/
|
||||
const updateExistingTable = await updateTable({
|
||||
dbFullName: dbFullName,
|
||||
tableName: tableName,
|
||||
dbFullName,
|
||||
tableName,
|
||||
tableFields: fields,
|
||||
userId,
|
||||
dbSchema: database,
|
||||
|
||||
@@ -2877,6 +2877,7 @@ export type APIPathsParams<
|
||||
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";
|
||||
@@ -2931,6 +2932,17 @@ export type APIPathsParamsCrudMiddleware<
|
||||
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