mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-15 21:16:17 +02:00
Move server directory outside of frontend src
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { prisma } from '../lib';
|
||||
import { AuthUser } from '../middleware';
|
||||
import { ApiError } from '../utils';
|
||||
|
||||
const findById = async (user: AuthUser, options: { id: string }) => {
|
||||
const { id } = options;
|
||||
|
||||
if (!user.isAdmin && user.id !== id) {
|
||||
throw ApiError.forbidden();
|
||||
}
|
||||
|
||||
const uniqueUser = await prisma.user.findUnique({
|
||||
include: { serverFolderPermissions: true },
|
||||
where: { id },
|
||||
});
|
||||
|
||||
if (!uniqueUser) {
|
||||
throw ApiError.notFound('');
|
||||
}
|
||||
|
||||
return uniqueUser;
|
||||
};
|
||||
|
||||
const findMany = async () => {
|
||||
const users = await prisma.user.findMany({});
|
||||
return users;
|
||||
};
|
||||
|
||||
export const usersService = {
|
||||
findById,
|
||||
findMany,
|
||||
};
|
||||
Reference in New Issue
Block a user