mirror of
https://github.com/outline/outline.git
synced 2026-12-05 18:55:10 +03:00
dataAttributes.delete endpoint
This commit is contained in:
1 parent
8120ef0ce8
commit
c950788ef1
2 files changed
+33
No files matched your search
@@ -111,4 +111,29 @@ router.post(
|
||||
}
|
||||
);
|
||||
|
||||
router.post(
|
||||
"dataAttributes.delete",
|
||||
auth({ role: UserRole.Admin }),
|
||||
validate(T.DataAttributesDeleteSchema),
|
||||
transaction(),
|
||||
async (ctx: APIContext<T.DataAttributesDeleteReq>) => {
|
||||
const { id } = ctx.input.body;
|
||||
const { user } = ctx.state.auth;
|
||||
const { transaction } = ctx.state;
|
||||
|
||||
const dataAttribute = await DataAttribute.findByPk(id, {
|
||||
lock: transaction.LOCK.UPDATE,
|
||||
rejectOnEmpty: true,
|
||||
transaction,
|
||||
});
|
||||
|
||||
authorize(user, "delete", dataAttribute);
|
||||
await dataAttribute.destroy({ transaction });
|
||||
|
||||
ctx.body = {
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
export default router;
|
||||
@@ -108,3 +108,11 @@ export const DataAttributesUpdateSchema = BaseSchema.extend({
|
||||
export type DataAttributesUpdateReq = z.infer<
|
||||
typeof DataAttributesUpdateSchema
|
||||
>;
|
||||
|
||||
export const DataAttributesDeleteSchema = BaseSchema.extend({
|
||||
body: BaseIdSchema,
|
||||
});
|
||||
|
||||
export type DataAttributesDeleteReq = z.infer<
|
||||
typeof DataAttributesDeleteSchema
|
||||
>;
|
||||
Reference in new issue
Block a user