mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(api): ✨ Add permissions to every route and permission config
This commit is contained in:
parent
19823d8eca
commit
4902f078a8
79 changed files with 729 additions and 251 deletions
|
|
@ -8,6 +8,7 @@ import {
|
|||
Instances,
|
||||
Notifications,
|
||||
Relationships,
|
||||
type Roles,
|
||||
Tokens,
|
||||
Users,
|
||||
} from "~/drizzle/schema";
|
||||
|
|
@ -31,6 +32,7 @@ export type UserWithRelations = UserType & {
|
|||
followerCount: number;
|
||||
followingCount: number;
|
||||
statusCount: number;
|
||||
roles: InferSelectModel<typeof Roles>[];
|
||||
};
|
||||
|
||||
export const userRelations: {
|
||||
|
|
@ -44,6 +46,11 @@ export const userRelations: {
|
|||
};
|
||||
};
|
||||
};
|
||||
roles: {
|
||||
with: {
|
||||
role: true;
|
||||
};
|
||||
};
|
||||
} = {
|
||||
instance: true,
|
||||
emojis: {
|
||||
|
|
@ -55,6 +62,11 @@ export const userRelations: {
|
|||
},
|
||||
},
|
||||
},
|
||||
roles: {
|
||||
with: {
|
||||
role: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const userExtras = {
|
||||
|
|
@ -242,6 +254,11 @@ export const transformOutputToUserWithRelations = (
|
|||
emoji?: EmojiWithInstance;
|
||||
}[];
|
||||
instance: InferSelectModel<typeof Instances> | null;
|
||||
roles: {
|
||||
userId: string;
|
||||
roleId: string;
|
||||
role?: InferSelectModel<typeof Roles>;
|
||||
}[];
|
||||
endpoints: unknown;
|
||||
},
|
||||
): UserWithRelations => {
|
||||
|
|
@ -266,6 +283,9 @@ export const transformOutputToUserWithRelations = (
|
|||
(emoji as unknown as Record<string, object>)
|
||||
.emoji as EmojiWithInstance,
|
||||
),
|
||||
roles: user.roles
|
||||
.map((role) => role.role)
|
||||
.filter(Boolean) as InferSelectModel<typeof Roles>[],
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue