chore: update biome configuration and enhance error handling in schema files
- Enabled useIgnoreFile in biome.json for better file management. - Updated various correctness and style rules in biome.json to enforce stricter coding standards. - Added new biome lint command in package.json for improved code quality checks. - Refactored error handling in multiple schema files to use consistent error throwing patterns, enhancing readability and maintainability. - Improved user authentication checks across various schemas to ensure proper access control.
This commit is contained in:
@@ -76,19 +76,25 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
}),
|
||||
},
|
||||
resolve: async (_query, _parent, args, ctx: SchemaContext) => {
|
||||
if (ctx.isSubscription) throw new Error('Not allowed')
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
const collaborationSession = await this.prisma.collaborationSession.findUnique({
|
||||
where: {
|
||||
scheduleDateId: args.scheduleDateId,
|
||||
},
|
||||
})
|
||||
if (!collaborationSession) throw new Error('Collaboration session not found')
|
||||
if (!collaborationSession) {
|
||||
throw new Error('Collaboration session not found')
|
||||
}
|
||||
const meetingRoom = await this.prisma.meetingRoom.findUnique({
|
||||
where: {
|
||||
collaborationSessionId: collaborationSession.id,
|
||||
},
|
||||
})
|
||||
if (meetingRoom) return meetingRoom
|
||||
if (meetingRoom) {
|
||||
return meetingRoom
|
||||
}
|
||||
return await this.prisma.meetingRoom.create({
|
||||
data: {
|
||||
collaborationSessionId: collaborationSession.id,
|
||||
@@ -106,19 +112,28 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
}),
|
||||
},
|
||||
resolve: async (_, args, ctx: SchemaContext) => {
|
||||
if (ctx.isSubscription) throw new Error('Not allowed')
|
||||
if (!ctx.http.me) throw new Error('Unauthorized')
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
if (!ctx.http.me) {
|
||||
throw new Error('Unauthorized')
|
||||
}
|
||||
const meetingRoom = await this.prisma.meetingRoom.findUnique({
|
||||
where: { collaborationSessionId: args.collaborationSessionId },
|
||||
})
|
||||
if (!meetingRoom) throw new Error('Meeting room not found')
|
||||
if (!meetingRoom) {
|
||||
throw new Error('Meeting room not found')
|
||||
}
|
||||
// check if user is collaborator of collaboration session
|
||||
const collaborationSession = await this.prisma.collaborationSession.findUnique({
|
||||
where: { id: meetingRoom.collaborationSessionId },
|
||||
})
|
||||
if (!collaborationSession) throw new Error('Collaboration session not found')
|
||||
if (!collaborationSession.collaboratorsIds.includes(ctx.http.me.id))
|
||||
if (!collaborationSession) {
|
||||
throw new Error('Collaboration session not found')
|
||||
}
|
||||
if (!collaborationSession.collaboratorsIds.includes(ctx.http.me.id)) {
|
||||
throw new Error('User is not collaborator')
|
||||
}
|
||||
// create new token
|
||||
const token = await this.livekitService.createToken(ctx.http.me, meetingRoom.id)
|
||||
return {
|
||||
@@ -144,8 +159,12 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
}),
|
||||
},
|
||||
resolve: async (query, _parent, args, ctx: SchemaContext) => {
|
||||
if (ctx.isSubscription) throw new Error('Not allowed')
|
||||
if (!ctx.http.me) throw new Error('Unauthorized')
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
if (!ctx.http.me) {
|
||||
throw new Error('Unauthorized')
|
||||
}
|
||||
return await this.prisma.meetingRoom.create({
|
||||
...query,
|
||||
data: args.input,
|
||||
@@ -166,8 +185,12 @@ export class MeetingRoomSchema extends PothosSchema {
|
||||
}),
|
||||
},
|
||||
resolve: async (query, _parent, args, ctx: SchemaContext) => {
|
||||
if (ctx.isSubscription) throw new Error('Not allowed')
|
||||
if (!ctx.http.me) throw new Error('Unauthorized')
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
if (!ctx.http.me) {
|
||||
throw new Error('Unauthorized')
|
||||
}
|
||||
return await this.prisma.meetingRoom.update({
|
||||
...query,
|
||||
where: {
|
||||
|
||||
Reference in New Issue
Block a user