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",
|
route: "/api/v1/statuses/:id",
|
||||||
auth: {
|
auth: {
|
||||||
required: false,
|
required: false,
|
||||||
requiredOnMethods: ["DELETE", "PUT"],
|
methodOverrides: {
|
||||||
|
DELETE: true,
|
||||||
|
PUT: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
permissions: {
|
permissions: {
|
||||||
required: [RolePermissions.ViewNotes],
|
required: [RolePermissions.ViewNotes],
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@ export interface ApiRouteMetadata {
|
||||||
route: string;
|
route: string;
|
||||||
auth: {
|
auth: {
|
||||||
required: boolean;
|
required: boolean;
|
||||||
requiredOnMethods?: HttpVerb[];
|
methodOverrides?: {
|
||||||
|
[Key in HttpVerb]?: boolean;
|
||||||
|
};
|
||||||
oauthPermissions?: string[];
|
oauthPermissions?: string[];
|
||||||
};
|
};
|
||||||
permissions?: {
|
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(
|
return context.json(
|
||||||
{
|
{
|
||||||
error: "Unauthorized",
|
error: "Unauthorized",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue