@studious-lms/server 1.1.24 → 1.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/lib/fileUpload.d.ts +2 -2
  2. package/dist/lib/fileUpload.d.ts.map +1 -1
  3. package/dist/lib/fileUpload.js +76 -14
  4. package/dist/lib/googleCloudStorage.d.ts +7 -0
  5. package/dist/lib/googleCloudStorage.d.ts.map +1 -1
  6. package/dist/lib/googleCloudStorage.js +19 -0
  7. package/dist/lib/notificationHandler.d.ts +25 -0
  8. package/dist/lib/notificationHandler.d.ts.map +1 -0
  9. package/dist/lib/notificationHandler.js +28 -0
  10. package/dist/routers/_app.d.ts +818 -78
  11. package/dist/routers/_app.d.ts.map +1 -1
  12. package/dist/routers/announcement.d.ts +290 -3
  13. package/dist/routers/announcement.d.ts.map +1 -1
  14. package/dist/routers/announcement.js +896 -10
  15. package/dist/routers/assignment.d.ts +70 -4
  16. package/dist/routers/assignment.d.ts.map +1 -1
  17. package/dist/routers/assignment.js +265 -131
  18. package/dist/routers/auth.js +1 -1
  19. package/dist/routers/file.d.ts +2 -0
  20. package/dist/routers/file.d.ts.map +1 -1
  21. package/dist/routers/file.js +9 -6
  22. package/dist/routers/labChat.d.ts.map +1 -1
  23. package/dist/routers/labChat.js +13 -5
  24. package/dist/routers/notifications.d.ts +8 -8
  25. package/dist/routers/section.d.ts +16 -0
  26. package/dist/routers/section.d.ts.map +1 -1
  27. package/dist/routers/section.js +139 -30
  28. package/dist/seedDatabase.d.ts +2 -2
  29. package/dist/seedDatabase.d.ts.map +1 -1
  30. package/dist/seedDatabase.js +2 -1
  31. package/dist/utils/logger.d.ts +1 -0
  32. package/dist/utils/logger.d.ts.map +1 -1
  33. package/dist/utils/logger.js +27 -2
  34. package/package.json +2 -2
  35. package/prisma/migrations/20251109122857_annuoncements_comments/migration.sql +30 -0
  36. package/prisma/migrations/20251109135555_reactions_announcements_comments/migration.sql +35 -0
  37. package/prisma/schema.prisma +50 -0
  38. package/src/lib/fileUpload.ts +79 -14
  39. package/src/lib/googleCloudStorage.ts +19 -0
  40. package/src/lib/notificationHandler.ts +36 -0
  41. package/src/routers/announcement.ts +1007 -10
  42. package/src/routers/assignment.ts +230 -82
  43. package/src/routers/auth.ts +1 -1
  44. package/src/routers/file.ts +10 -7
  45. package/src/routers/labChat.ts +15 -6
  46. package/src/routers/section.ts +158 -36
  47. package/src/seedDatabase.ts +2 -1
  48. package/src/utils/logger.ts +29 -2
  49. package/tests/setup.ts +3 -9
@@ -62,4 +62,23 @@ export async function deleteFile(filePath: string): Promise<void> {
62
62
  message: 'Failed to delete file from storage',
63
63
  });
64
64
  }
65
+ }
66
+
67
+ /**
68
+ * Checks if an object exists in Google Cloud Storage
69
+ * @param bucketName The name of the bucket (unused, uses default bucket)
70
+ * @param objectPath The path of the object to check
71
+ * @returns Promise<boolean> True if the object exists, false otherwise
72
+ */
73
+ export async function objectExists(bucketName: string, objectPath: string): Promise<boolean> {
74
+ try {
75
+ const [exists] = await bucket.file(objectPath).exists();
76
+ return exists;
77
+ } catch (error) {
78
+ console.error('Error checking if object exists in Google Cloud Storage:', error);
79
+ throw new TRPCError({
80
+ code: 'INTERNAL_SERVER_ERROR',
81
+ message: 'Failed to check object existence',
82
+ });
83
+ }
65
84
  }
@@ -0,0 +1,36 @@
1
+ import { prisma } from "./prisma.js";
2
+
3
+ interface notificationData {
4
+ title: string,
5
+ content: string
6
+ }
7
+
8
+ export async function sendNotification(receiver: string, data: notificationData) {
9
+ const notification = await prisma.notification.create({
10
+ data: {
11
+ receiverId: receiver,
12
+ title: data.title,
13
+ content: data.content,
14
+ },
15
+ });
16
+ return notification;
17
+ }
18
+
19
+ export async function sendNotifications(receiverIds: Array<string>, data: notificationData) {
20
+ const notifications = await prisma.notification.createMany({
21
+ data: receiverIds.map(receiverId => ({
22
+ receiverId: receiverId,
23
+ title: data.title,
24
+ content: data.content,
25
+ })),
26
+ });
27
+ return notifications;
28
+ }
29
+
30
+ export async function markRead(id: string, read: boolean = true) {
31
+ const notification = await prisma.notification.update({
32
+ where: {id},
33
+ data: {read: read},
34
+ });
35
+ return notification;
36
+ }