mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
fix(email-themes): add missing DELETE route so themes can be deleted
The dashboard's deleteEmailTheme() sends DELETE /internal/email-themes/{id},
but the [id] route only exported GET and PATCH, so Next.js returned 405 and
the UI showed 'Theme not deleted'. Wire up a DELETE handler that reuses the
existing CUD onDelete logic (including the active-theme guard).
This commit is contained in:
@@ -51,3 +51,37 @@ export const PATCH = createSmartRouteHandler({
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export const DELETE = createSmartRouteHandler({
|
||||
metadata: {
|
||||
hidden: true,
|
||||
},
|
||||
request: yupObject({
|
||||
auth: yupObject({
|
||||
type: yupString().oneOf(["admin"]).defined(),
|
||||
tenancy: adaptSchema.defined(),
|
||||
}).defined(),
|
||||
params: yupObject({
|
||||
id: yupString().defined(),
|
||||
}).defined(),
|
||||
}),
|
||||
response: yupObject({
|
||||
statusCode: yupNumber().oneOf([200]).defined(),
|
||||
bodyType: yupString().oneOf(["json"]).defined(),
|
||||
body: yupObject({}).defined(),
|
||||
}),
|
||||
async handler({ auth: { tenancy }, params: { id } }) {
|
||||
await internalEmailThemesCudHandlers.adminDelete({
|
||||
tenancy,
|
||||
allowedErrorTypes: [StatusError],
|
||||
id,
|
||||
data: [],
|
||||
});
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
bodyType: "json",
|
||||
body: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user