mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
refactor(api): 🚚 Change ApiRouteMetadata structure to be more consistent
This commit is contained in:
parent
00fd751c2a
commit
924ff9b2d4
|
|
@ -25,7 +25,10 @@ export const meta = applyConfig({
|
|||
route: "/api/v1/statuses/:id",
|
||||
auth: {
|
||||
required: false,
|
||||
requiredOnMethods: ["DELETE", "PUT"],
|
||||
methodOverrides: {
|
||||
DELETE: true,
|
||||
PUT: true,
|
||||
},
|
||||
},
|
||||
permissions: {
|
||||
required: [RolePermissions.ViewNotes],
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ export interface ApiRouteMetadata {
|
|||
route: string;
|
||||
auth: {
|
||||
required: boolean;
|
||||
requiredOnMethods?: HttpVerb[];
|
||||
methodOverrides?: {
|
||||
[Key in HttpVerb]?: boolean;
|
||||
};
|
||||
oauthPermissions?: string[];
|
||||
};
|
||||
permissions?: {
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ const checkRouteNeedsAuth = (
|
|||
);
|
||||
}
|
||||
|
||||
if (authData.requiredOnMethods?.includes(context.req.method as HttpVerb)) {
|
||||
if (authData.methodOverrides?.[context.req.method as HttpVerb]) {
|
||||
return context.json(
|
||||
{
|
||||
error: "Unauthorized",
|
||||
|
|
|
|||
Loading…
Reference in a new issue