@studious-lms/server 1.1.24 → 1.2.6
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.
- package/.coderabbit.yaml +9 -0
- package/.env.example +53 -0
- package/.env.test.example +37 -0
- package/README.md +34 -7
- package/dist/exportType.d.ts.map +1 -1
- package/dist/exportType.js +4 -0
- package/dist/exportType.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +212 -51
- package/dist/index.js.map +1 -0
- package/dist/instrument.d.ts +2 -0
- package/dist/instrument.d.ts.map +1 -0
- package/dist/instrument.js +18 -0
- package/dist/instrument.js.map +1 -0
- package/dist/lib/config/env.d.ts +190 -0
- package/dist/lib/config/env.d.ts.map +1 -0
- package/dist/lib/config/env.js +121 -0
- package/dist/lib/config/env.js.map +1 -0
- package/dist/lib/fileUpload.d.ts +2 -2
- package/dist/lib/fileUpload.d.ts.map +1 -1
- package/dist/lib/fileUpload.js +82 -15
- package/dist/lib/fileUpload.js.map +1 -0
- package/dist/lib/googleCloudStorage.d.ts +13 -0
- package/dist/lib/googleCloudStorage.d.ts.map +1 -1
- package/dist/lib/googleCloudStorage.js +45 -6
- package/dist/lib/googleCloudStorage.js.map +1 -0
- package/dist/lib/jsonConversion.d.ts.map +1 -1
- package/dist/lib/jsonConversion.js +16 -14
- package/dist/lib/jsonConversion.js.map +1 -0
- package/dist/lib/jsonStyles.d.ts.map +1 -1
- package/dist/lib/jsonStyles.js +4 -0
- package/dist/lib/jsonStyles.js.map +1 -0
- package/dist/lib/notificationHandler.d.ts +25 -0
- package/dist/lib/notificationHandler.d.ts.map +1 -0
- package/dist/lib/notificationHandler.js +32 -0
- package/dist/lib/notificationHandler.js.map +1 -0
- package/dist/lib/prisma.d.ts +2 -2
- package/dist/lib/prisma.d.ts.map +1 -1
- package/dist/lib/prisma.js +24 -1
- package/dist/lib/prisma.js.map +1 -0
- package/dist/lib/pusher.d.ts +4 -1
- package/dist/lib/pusher.d.ts.map +1 -1
- package/dist/lib/pusher.js +14 -6
- package/dist/lib/pusher.js.map +1 -0
- package/dist/lib/redis.d.ts +5 -0
- package/dist/lib/redis.d.ts.map +1 -0
- package/dist/lib/redis.js +53 -0
- package/dist/lib/redis.js.map +1 -0
- package/dist/lib/thumbnailGenerator.d.ts +0 -21
- package/dist/lib/thumbnailGenerator.d.ts.map +1 -1
- package/dist/lib/thumbnailGenerator.js +159 -158
- package/dist/lib/thumbnailGenerator.js.map +1 -0
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +41 -93
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/logging.d.ts.map +1 -1
- package/dist/middleware/logging.js +4 -0
- package/dist/middleware/logging.js.map +1 -0
- package/dist/middleware/security.d.ts +5 -0
- package/dist/middleware/security.d.ts.map +1 -0
- package/dist/middleware/security.js +77 -0
- package/dist/middleware/security.js.map +1 -0
- package/dist/models/agenda.d.ts +97 -0
- package/dist/models/agenda.d.ts.map +1 -0
- package/dist/models/agenda.js +40 -0
- package/dist/models/agenda.js.map +1 -0
- package/dist/models/announcement.d.ts +223 -0
- package/dist/models/announcement.d.ts.map +1 -0
- package/dist/models/announcement.js +120 -0
- package/dist/models/announcement.js.map +1 -0
- package/dist/models/assignment.d.ts +1292 -0
- package/dist/models/assignment.d.ts.map +1 -0
- package/dist/models/assignment.js +309 -0
- package/dist/models/assignment.js.map +1 -0
- package/dist/models/attendance.d.ts +180 -0
- package/dist/models/attendance.d.ts.map +1 -0
- package/dist/models/attendance.js +188 -0
- package/dist/models/attendance.js.map +1 -0
- package/dist/models/auth.d.ts +153 -0
- package/dist/models/auth.d.ts.map +1 -0
- package/dist/models/auth.js +217 -0
- package/dist/models/auth.js.map +1 -0
- package/dist/models/class.d.ts +439 -0
- package/dist/models/class.d.ts.map +1 -0
- package/dist/models/class.js +546 -0
- package/dist/models/class.js.map +1 -0
- package/dist/models/comment.d.ts +171 -0
- package/dist/models/comment.d.ts.map +1 -0
- package/dist/models/comment.js +138 -0
- package/dist/models/comment.js.map +1 -0
- package/dist/models/conversation.d.ts +164 -0
- package/dist/models/conversation.d.ts.map +1 -0
- package/dist/models/conversation.js +175 -0
- package/dist/models/conversation.js.map +1 -0
- package/dist/models/event.d.ts +295 -0
- package/dist/models/event.d.ts.map +1 -0
- package/dist/models/event.js +145 -0
- package/dist/models/event.js.map +1 -0
- package/dist/models/file.d.ts +536 -0
- package/dist/models/file.d.ts.map +1 -0
- package/dist/models/file.js +126 -0
- package/dist/models/file.js.map +1 -0
- package/dist/models/folder.d.ts +295 -0
- package/dist/models/folder.d.ts.map +1 -0
- package/dist/models/folder.js +202 -0
- package/dist/models/folder.js.map +1 -0
- package/dist/models/labChat.d.ts +243 -0
- package/dist/models/labChat.d.ts.map +1 -0
- package/dist/models/labChat.js +204 -0
- package/dist/models/labChat.js.map +1 -0
- package/dist/models/marketing.d.ts +72 -0
- package/dist/models/marketing.d.ts.map +1 -0
- package/dist/models/marketing.js +26 -0
- package/dist/models/marketing.js.map +1 -0
- package/dist/models/message.d.ts +100 -0
- package/dist/models/message.d.ts.map +1 -0
- package/dist/models/message.js +131 -0
- package/dist/models/message.js.map +1 -0
- package/dist/models/newtonChat.d.ts +72 -0
- package/dist/models/newtonChat.d.ts.map +1 -0
- package/dist/models/newtonChat.js +61 -0
- package/dist/models/newtonChat.js.map +1 -0
- package/dist/models/notification.d.ts +65 -0
- package/dist/models/notification.d.ts.map +1 -0
- package/dist/models/notification.js +46 -0
- package/dist/models/notification.js.map +1 -0
- package/dist/models/section.d.ts +102 -0
- package/dist/models/section.d.ts.map +1 -0
- package/dist/models/section.js +83 -0
- package/dist/models/section.js.map +1 -0
- package/dist/models/user.d.ts +39 -0
- package/dist/models/user.d.ts.map +1 -0
- package/dist/models/user.js +38 -0
- package/dist/models/user.js.map +1 -0
- package/dist/models/worksheet.d.ts +460 -0
- package/dist/models/worksheet.d.ts.map +1 -0
- package/dist/models/worksheet.js +200 -0
- package/dist/models/worksheet.js.map +1 -0
- package/dist/pipelines/aiLabChat.d.ts +21 -0
- package/dist/pipelines/aiLabChat.d.ts.map +1 -0
- package/dist/pipelines/aiLabChat.js +460 -0
- package/dist/pipelines/aiLabChat.js.map +1 -0
- package/dist/pipelines/aiNewtonChat.d.ts +30 -0
- package/dist/pipelines/aiNewtonChat.d.ts.map +1 -0
- package/dist/pipelines/aiNewtonChat.js +289 -0
- package/dist/pipelines/aiNewtonChat.js.map +1 -0
- package/dist/pipelines/gradeWorksheet.d.ts +30 -0
- package/dist/pipelines/gradeWorksheet.d.ts.map +1 -0
- package/dist/pipelines/gradeWorksheet.js +252 -0
- package/dist/pipelines/gradeWorksheet.js.map +1 -0
- package/dist/routers/_app.d.ts +6403 -3741
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/_app.js +10 -0
- package/dist/routers/_app.js.map +1 -0
- package/dist/routers/agenda.d.ts +58 -6
- package/dist/routers/agenda.d.ts.map +1 -1
- package/dist/routers/agenda.js +6 -58
- package/dist/routers/agenda.js.map +1 -0
- package/dist/routers/announcement.d.ts +325 -6
- package/dist/routers/announcement.d.ts.map +1 -1
- package/dist/routers/announcement.js +547 -57
- package/dist/routers/announcement.js.map +1 -0
- package/dist/routers/assignment.d.ts +431 -318
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +104 -1559
- package/dist/routers/assignment.js.map +1 -0
- package/dist/routers/attendance.d.ts +20 -9
- package/dist/routers/attendance.d.ts.map +1 -1
- package/dist/routers/attendance.js +10 -263
- package/dist/routers/attendance.js.map +1 -0
- package/dist/routers/auth.d.ts +21 -1
- package/dist/routers/auth.d.ts.map +1 -1
- package/dist/routers/auth.js +37 -241
- package/dist/routers/auth.js.map +1 -0
- package/dist/routers/class.d.ts +198 -68
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/class.js +88 -909
- package/dist/routers/class.js.map +1 -0
- package/dist/routers/comment.d.ts +153 -0
- package/dist/routers/comment.d.ts.map +1 -0
- package/dist/routers/comment.js +58 -0
- package/dist/routers/comment.js.map +1 -0
- package/dist/routers/conversation.d.ts +73 -3
- package/dist/routers/conversation.d.ts.map +1 -1
- package/dist/routers/conversation.js +23 -265
- package/dist/routers/conversation.js.map +1 -0
- package/dist/routers/event.d.ts +46 -37
- package/dist/routers/event.d.ts.map +1 -1
- package/dist/routers/event.js +15 -431
- package/dist/routers/event.js.map +1 -0
- package/dist/routers/file.d.ts +4 -2
- package/dist/routers/file.d.ts.map +1 -1
- package/dist/routers/file.js +11 -295
- package/dist/routers/file.js.map +1 -0
- package/dist/routers/folder.d.ts +21 -14
- package/dist/routers/folder.d.ts.map +1 -1
- package/dist/routers/folder.js +36 -743
- package/dist/routers/folder.js.map +1 -0
- package/dist/routers/labChat.d.ts +12 -9
- package/dist/routers/labChat.d.ts.map +1 -1
- package/dist/routers/labChat.js +21 -877
- package/dist/routers/labChat.js.map +1 -0
- package/dist/routers/marketing.d.ts +2 -2
- package/dist/routers/marketing.d.ts.map +1 -1
- package/dist/routers/marketing.js +9 -54
- package/dist/routers/marketing.js.map +1 -0
- package/dist/routers/message.d.ts +2 -1
- package/dist/routers/message.d.ts.map +1 -1
- package/dist/routers/message.js +29 -519
- package/dist/routers/message.js.map +1 -0
- package/dist/routers/newtonChat.d.ts +55 -0
- package/dist/routers/newtonChat.d.ts.map +1 -0
- package/dist/routers/newtonChat.js +22 -0
- package/dist/routers/newtonChat.js.map +1 -0
- package/dist/routers/notifications.d.ts +8 -8
- package/dist/routers/notifications.d.ts.map +1 -1
- package/dist/routers/notifications.js +20 -81
- package/dist/routers/notifications.js.map +1 -0
- package/dist/routers/section.d.ts +37 -6
- package/dist/routers/section.d.ts.map +1 -1
- package/dist/routers/section.js +26 -167
- package/dist/routers/section.js.map +1 -0
- package/dist/routers/user.d.ts +1 -1
- package/dist/routers/user.d.ts.map +1 -1
- package/dist/routers/user.js +34 -204
- package/dist/routers/user.js.map +1 -0
- package/dist/routers/worksheet.d.ts +362 -0
- package/dist/routers/worksheet.d.ts.map +1 -0
- package/dist/routers/worksheet.js +153 -0
- package/dist/routers/worksheet.js.map +1 -0
- package/dist/seedDatabase.d.ts +2 -3
- package/dist/seedDatabase.d.ts.map +1 -1
- package/dist/seedDatabase.js +311 -289
- package/dist/seedDatabase.js.map +1 -0
- package/dist/server/pipelines/aiLabChat.d.ts +21 -0
- package/dist/server/pipelines/aiLabChat.d.ts.map +1 -0
- package/dist/server/pipelines/aiLabChat.js +456 -0
- package/dist/server/pipelines/aiLabChat.js.map +1 -0
- package/dist/server/pipelines/aiNewtonChat.d.ts +30 -0
- package/dist/server/pipelines/aiNewtonChat.d.ts.map +1 -0
- package/dist/server/pipelines/aiNewtonChat.js +285 -0
- package/dist/server/pipelines/aiNewtonChat.js.map +1 -0
- package/dist/server/pipelines/gradeWorksheet.d.ts +30 -0
- package/dist/server/pipelines/gradeWorksheet.d.ts.map +1 -0
- package/dist/server/pipelines/gradeWorksheet.js +248 -0
- package/dist/server/pipelines/gradeWorksheet.js.map +1 -0
- package/dist/services/agenda.d.ts +100 -0
- package/dist/services/agenda.d.ts.map +1 -0
- package/dist/services/agenda.js +21 -0
- package/dist/services/agenda.js.map +1 -0
- package/dist/services/announcement.d.ts +135 -0
- package/dist/services/announcement.d.ts.map +1 -0
- package/dist/services/announcement.js +223 -0
- package/dist/services/announcement.js.map +1 -0
- package/dist/services/assignment.d.ts +1462 -0
- package/dist/services/assignment.d.ts.map +1 -0
- package/dist/services/assignment.js +898 -0
- package/dist/services/assignment.js.map +1 -0
- package/dist/services/attendance.d.ts +93 -0
- package/dist/services/attendance.d.ts.map +1 -0
- package/dist/services/attendance.js +61 -0
- package/dist/services/attendance.js.map +1 -0
- package/dist/services/auth.d.ts +68 -0
- package/dist/services/auth.d.ts.map +1 -0
- package/dist/services/auth.js +218 -0
- package/dist/services/auth.js.map +1 -0
- package/dist/services/class.d.ts +621 -0
- package/dist/services/class.d.ts.map +1 -0
- package/dist/services/class.js +474 -0
- package/dist/services/class.js.map +1 -0
- package/dist/services/comment.d.ts +100 -0
- package/dist/services/comment.d.ts.map +1 -0
- package/dist/services/comment.js +83 -0
- package/dist/services/comment.js.map +1 -0
- package/dist/services/conversation.d.ts +159 -0
- package/dist/services/conversation.d.ts.map +1 -0
- package/dist/services/conversation.js +138 -0
- package/dist/services/conversation.js.map +1 -0
- package/dist/services/event.d.ts +216 -0
- package/dist/services/event.d.ts.map +1 -0
- package/dist/services/event.js +168 -0
- package/dist/services/event.js.map +1 -0
- package/dist/services/file.d.ts +74 -0
- package/dist/services/file.d.ts.map +1 -0
- package/dist/services/file.js +133 -0
- package/dist/services/file.js.map +1 -0
- package/dist/services/folder.d.ts +239 -0
- package/dist/services/folder.d.ts.map +1 -0
- package/dist/services/folder.js +248 -0
- package/dist/services/folder.js.map +1 -0
- package/dist/services/labChat.d.ts +165 -0
- package/dist/services/labChat.d.ts.map +1 -0
- package/dist/services/labChat.js +289 -0
- package/dist/services/labChat.js.map +1 -0
- package/dist/services/marketing.d.ts +50 -0
- package/dist/services/marketing.d.ts.map +1 -0
- package/dist/services/marketing.js +32 -0
- package/dist/services/marketing.js.map +1 -0
- package/dist/services/message.d.ts +95 -0
- package/dist/services/message.d.ts.map +1 -0
- package/dist/services/message.js +350 -0
- package/dist/services/message.js.map +1 -0
- package/dist/services/newtonChat.d.ts +22 -0
- package/dist/services/newtonChat.d.ts.map +1 -0
- package/dist/services/newtonChat.js +174 -0
- package/dist/services/newtonChat.js.map +1 -0
- package/dist/services/notification.d.ts +65 -0
- package/dist/services/notification.d.ts.map +1 -0
- package/dist/services/notification.js +33 -0
- package/dist/services/notification.js.map +1 -0
- package/dist/services/section.d.ts +53 -0
- package/dist/services/section.d.ts.map +1 -0
- package/dist/services/section.js +199 -0
- package/dist/services/section.js.map +1 -0
- package/dist/services/user.d.ts +48 -0
- package/dist/services/user.d.ts.map +1 -0
- package/dist/services/user.js +141 -0
- package/dist/services/user.js.map +1 -0
- package/dist/services/worksheet.d.ts +239 -0
- package/dist/services/worksheet.d.ts.map +1 -0
- package/dist/services/worksheet.js +235 -0
- package/dist/services/worksheet.js.map +1 -0
- package/dist/socket/handlers.d.ts.map +1 -1
- package/dist/socket/handlers.js +4 -0
- package/dist/socket/handlers.js.map +1 -0
- package/dist/trpc.d.ts.map +1 -1
- package/dist/trpc.js +4 -0
- package/dist/trpc.js.map +1 -0
- package/dist/types/trpc.d.ts.map +1 -1
- package/dist/types/trpc.js +4 -0
- package/dist/types/trpc.js.map +1 -0
- package/dist/utils/aiUser.d.ts +1 -3
- package/dist/utils/aiUser.d.ts.map +1 -1
- package/dist/utils/aiUser.js +8 -3
- package/dist/utils/aiUser.js.map +1 -0
- package/dist/utils/email.d.ts +12 -1
- package/dist/utils/email.d.ts.map +1 -1
- package/dist/utils/email.js +26 -4
- package/dist/utils/email.js.map +1 -0
- package/dist/utils/generateInviteCode.d.ts +1 -2
- package/dist/utils/generateInviteCode.d.ts.map +1 -1
- package/dist/utils/generateInviteCode.js +5 -2
- package/dist/utils/generateInviteCode.js.map +1 -0
- package/dist/utils/inference.d.ts +8 -0
- package/dist/utils/inference.d.ts.map +1 -1
- package/dist/utils/inference.js +78 -10
- package/dist/utils/inference.js.map +1 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +35 -3
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/prismaErrorHandler.d.ts.map +1 -1
- package/dist/utils/prismaErrorHandler.js +7 -0
- package/dist/utils/prismaErrorHandler.js.map +1 -0
- package/dist/utils/prismaWrapper.d.ts +1 -0
- package/dist/utils/prismaWrapper.d.ts.map +1 -1
- package/dist/utils/prismaWrapper.js +8 -0
- package/dist/utils/prismaWrapper.js.map +1 -0
- package/docker-compose.yml +19 -0
- package/package.json +21 -4
- package/prisma/migrations/20251109122857_annuoncements_comments/migration.sql +30 -0
- package/prisma/migrations/20251109135555_reactions_announcements_comments/migration.sql +35 -0
- package/prisma/schema.prisma +180 -12
- package/scripts/test-pre-push.ts +14 -0
- package/src/index.ts +247 -52
- package/src/instrument.ts +15 -0
- package/src/lib/config/env.ts +132 -0
- package/src/lib/fileUpload.ts +81 -16
- package/src/lib/googleCloudStorage.ts +42 -6
- package/src/lib/jsonConversion.ts +12 -14
- package/src/lib/prisma.ts +23 -2
- package/src/lib/pusher.ts +11 -6
- package/src/lib/redis.ts +56 -0
- package/src/lib/thumbnailGenerator.ts +170 -168
- package/src/middleware/auth.ts +86 -137
- package/src/middleware/security.ts +80 -0
- package/src/models/agenda.ts +46 -0
- package/src/models/announcement.ts +134 -0
- package/src/models/assignment.ts +322 -0
- package/src/models/attendance.ts +208 -0
- package/src/models/auth.ts +247 -0
- package/src/models/class.ts +598 -0
- package/src/models/comment.ts +152 -0
- package/src/models/conversation.ts +200 -0
- package/src/models/event.ts +177 -0
- package/src/models/file.ts +129 -0
- package/src/models/folder.ts +225 -0
- package/src/models/labChat.ts +213 -0
- package/src/models/marketing.ts +45 -0
- package/src/models/message.ts +153 -0
- package/src/models/newtonChat.ts +70 -0
- package/src/models/notification.ts +54 -0
- package/src/models/section.ts +98 -0
- package/src/models/user.ts +47 -0
- package/src/models/worksheet.ts +294 -0
- package/src/pipelines/aiLabChat.ts +511 -0
- package/src/pipelines/aiNewtonChat.ts +347 -0
- package/src/pipelines/gradeWorksheet.ts +286 -0
- package/src/routers/_app.ts +6 -0
- package/src/routers/agenda.ts +3 -61
- package/src/routers/announcement.ts +622 -57
- package/src/routers/assignment.ts +157 -1688
- package/src/routers/attendance.ts +16 -277
- package/src/routers/auth.ts +79 -313
- package/src/routers/class.ts +265 -1038
- package/src/routers/comment.ts +76 -0
- package/src/routers/conversation.ts +53 -284
- package/src/routers/event.ts +50 -481
- package/src/routers/file.ts +45 -341
- package/src/routers/folder.ts +107 -836
- package/src/routers/labChat.ts +29 -960
- package/src/routers/marketing.ts +35 -77
- package/src/routers/message.ts +45 -571
- package/src/routers/newtonChat.ts +36 -0
- package/src/routers/notifications.ts +32 -82
- package/src/routers/section.ts +58 -200
- package/src/routers/user.ts +49 -226
- package/src/routers/worksheet.ts +252 -0
- package/src/seedDatabase.ts +330 -290
- package/src/services/agenda.ts +21 -0
- package/src/services/announcement.ts +290 -0
- package/src/services/assignment.ts +1198 -0
- package/src/services/attendance.ts +85 -0
- package/src/services/auth.ts +277 -0
- package/src/services/class.ts +622 -0
- package/src/services/comment.ts +106 -0
- package/src/services/conversation.ts +213 -0
- package/src/services/event.ts +231 -0
- package/src/services/file.ts +167 -0
- package/src/services/folder.ts +316 -0
- package/src/services/labChat.ts +352 -0
- package/src/services/marketing.ts +57 -0
- package/src/services/message.ts +461 -0
- package/src/services/newtonChat.ts +222 -0
- package/src/services/notification.ts +50 -0
- package/src/services/section.ts +283 -0
- package/src/services/user.ts +172 -0
- package/src/services/worksheet.ts +358 -0
- package/src/trpc.ts +4 -0
- package/src/utils/aiUser.ts +4 -3
- package/src/utils/email.ts +33 -4
- package/src/utils/generateInviteCode.ts +1 -3
- package/src/utils/inference.ts +89 -10
- package/src/utils/logger.ts +33 -3
- package/src/utils/prismaErrorHandler.ts +3 -0
- package/src/utils/prismaWrapper.ts +4 -0
- package/tests/globalSetup.ts +62 -0
- package/tests/helpers.ts +22 -0
- package/tests/middleware/security.test.ts +42 -0
- package/tests/routers/agenda.test.ts +138 -0
- package/tests/routers/announcement.test.ts +490 -0
- package/tests/routers/assignment.test.ts +837 -0
- package/tests/routers/attendance.test.ts +160 -0
- package/tests/routers/auth.test.ts +171 -0
- package/tests/{class.test.ts → routers/class.test.ts} +163 -92
- package/tests/routers/comment.test.ts +126 -0
- package/tests/routers/conversation.test.ts +145 -0
- package/tests/routers/event.test.ts +289 -0
- package/tests/routers/folder.test.ts +178 -0
- package/tests/routers/labChat.test.ts +115 -0
- package/tests/routers/marketing.test.ts +59 -0
- package/tests/routers/message.test.ts +123 -0
- package/tests/routers/notification.test.ts +69 -0
- package/tests/routers/section.test.ts +208 -0
- package/tests/server/rateLimit.test.ts +73 -0
- package/tests/setup.ts +39 -65
- package/tests/user.test.ts +136 -0
- package/tests/utils/aiUser.test.ts +22 -0
- package/tests/utils/generateInviteCode.test.ts +24 -0
- package/tests/utils/logger.test.ts +74 -0
- package/tests/utils/prismaErrorHandler.test.ts +101 -0
- package/tests/utils/prismaWrapper.test.ts +82 -0
- package/tests/worksheet.test.ts +181 -0
- package/tsconfig.json +9 -2
- package/vitest.config.ts +30 -1
- package/vitest.unit.config.ts +21 -0
- package/API_SPECIFICATION.md +0 -1597
- package/BASE64_REMOVAL_SUMMARY.md +0 -164
- package/CHAT_API_SPEC.md +0 -579
- package/LAB_CHAT_API_SPEC.md +0 -518
- package/dist/routers/school.d.ts +0 -208
- package/dist/routers/school.d.ts.map +0 -1
- package/dist/routers/school.js +0 -481
- package/tests/auth.test.ts +0 -25
package/.coderabbit.yaml
ADDED
package/.env.example
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Environment Configuration
|
|
2
|
+
# Copy this file to .env and fill in your values
|
|
3
|
+
|
|
4
|
+
# Database Configuration
|
|
5
|
+
# PostgreSQL connection string
|
|
6
|
+
DATABASE_URL="postgresql://postgres:password@localhost:5432/postgres"
|
|
7
|
+
DIRECT_URL="postgresql://postgres:password@localhost:5432/postgres"
|
|
8
|
+
|
|
9
|
+
# Application Configuration
|
|
10
|
+
# Frontend URL for CORS configuration
|
|
11
|
+
NEXT_PUBLIC_APP_URL="http://localhost:3000"
|
|
12
|
+
# Server port
|
|
13
|
+
PORT=3001
|
|
14
|
+
# Environment: development, test, production
|
|
15
|
+
NODE_ENV=development
|
|
16
|
+
|
|
17
|
+
# Logging Configuration
|
|
18
|
+
# Options: debug, info, warn, error
|
|
19
|
+
LOG_MODE=info
|
|
20
|
+
|
|
21
|
+
# Google Cloud Storage Configuration
|
|
22
|
+
# Required for file uploads and storage
|
|
23
|
+
GOOGLE_CLOUD_PROJECT_ID="your-project-id"
|
|
24
|
+
GOOGLE_CLOUD_CLIENT_EMAIL="your-service-account@your-project.iam.gserviceaccount.com"
|
|
25
|
+
GOOGLE_CLOUD_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
|
|
26
|
+
YOUR_PRIVATE_KEY
|
|
27
|
+
-----END PRIVATE KEY-----"
|
|
28
|
+
GOOGLE_CLOUD_BUCKET_NAME="your-bucket-name"
|
|
29
|
+
|
|
30
|
+
# Pusher Configuration
|
|
31
|
+
# Required for real-time notifications (chat, worksheet grading)
|
|
32
|
+
PUSHER_APP_ID="your-app-id"
|
|
33
|
+
PUSHER_KEY="your-key"
|
|
34
|
+
PUSHER_SECRET="your-secret"
|
|
35
|
+
PUSHER_CLUSTER="your-cluster"
|
|
36
|
+
|
|
37
|
+
# Frontend must set these to match (for real-time chat to work):
|
|
38
|
+
# NEXT_PUBLIC_PUSHER_KEY=<same as PUSHER_KEY>
|
|
39
|
+
# NEXT_PUBLIC_PUSHER_CLUSTER=<same as PUSHER_CLUSTER>
|
|
40
|
+
# NEXT_PUBLIC_API_URL=<backend URL, e.g. http://localhost:3001>
|
|
41
|
+
|
|
42
|
+
# Redis (optional - for caching, rate limiting, etc.)
|
|
43
|
+
REDIS_URL="redis://localhost:6379"
|
|
44
|
+
|
|
45
|
+
# AI/Inference Configuration
|
|
46
|
+
# Required for AI features (lab chat, etc.)
|
|
47
|
+
INFERENCE_API_KEY="your-api-key"
|
|
48
|
+
INFERENCE_API_BASE_URL="https://api.openai.com/v1"
|
|
49
|
+
|
|
50
|
+
# Sentry Configuration
|
|
51
|
+
# Required for error tracking and monitoring
|
|
52
|
+
SENTRY_AUTH_TOKEN="your-auth-token"
|
|
53
|
+
SENTRY_DSN="https://your-key@your-org.ingest.sentry.io/your-project"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Test Environment Configuration
|
|
2
|
+
# Copy this file to .env.test and fill in your test values
|
|
3
|
+
|
|
4
|
+
# Database Configuration (use a separate test database)
|
|
5
|
+
DATABASE_URL="postgresql://postgres:password@localhost:5434/postgres"
|
|
6
|
+
DIRECT_URL="postgresql://postgres:password@localhost:5434/postgres"
|
|
7
|
+
|
|
8
|
+
# Application Configuration
|
|
9
|
+
NEXT_PUBLIC_APP_URL="http://localhost:3000"
|
|
10
|
+
PORT=3002
|
|
11
|
+
NODE_ENV=test
|
|
12
|
+
|
|
13
|
+
# Logging Configuration
|
|
14
|
+
# Options: debug, info, warn, error
|
|
15
|
+
LOG_MODE=error
|
|
16
|
+
|
|
17
|
+
# Google Cloud Storage (optional for tests - can use mock/local storage)
|
|
18
|
+
GOOGLE_CLOUD_PROJECT_ID="your-test-project-id"
|
|
19
|
+
GOOGLE_CLOUD_CLIENT_EMAIL="test@test-project.iam.gserviceaccount.com"
|
|
20
|
+
GOOGLE_CLOUD_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
|
|
21
|
+
YOUR_TEST_PRIVATE_KEY
|
|
22
|
+
-----END PRIVATE KEY-----"
|
|
23
|
+
GOOGLE_CLOUD_BUCKET_NAME="test-bucket-name"
|
|
24
|
+
|
|
25
|
+
# Pusher Configuration (optional for tests - can be mocked)
|
|
26
|
+
PUSHER_APP_ID="test-app-id"
|
|
27
|
+
PUSHER_KEY="test-key"
|
|
28
|
+
PUSHER_SECRET="test-secret"
|
|
29
|
+
PUSHER_CLUSTER="us2"
|
|
30
|
+
|
|
31
|
+
# AI/Inference Configuration (optional for tests - should be mocked)
|
|
32
|
+
INFERENCE_API_KEY="test-api-key"
|
|
33
|
+
INFERENCE_API_BASE_URL="http://localhost:11434/v1"
|
|
34
|
+
|
|
35
|
+
# Sentry Configuration (disabled for tests)
|
|
36
|
+
SENTRY_AUTH_TOKEN="test-auth-token"
|
|
37
|
+
SENTRY_DSN="https://test@test.ingest.sentry.io/test"
|
package/README.md
CHANGED
|
@@ -34,14 +34,11 @@ This is the backend server for the Studious application. It provides a RESTful a
|
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
3. **Set up environment variables:**
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
PORT=3001
|
|
41
|
-
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
|
42
|
-
NODE_ENV=development
|
|
43
|
-
LOG_MODE=info
|
|
37
|
+
Copy the example environment file and update with your values:
|
|
38
|
+
```bash
|
|
39
|
+
cp .env.example .env
|
|
44
40
|
```
|
|
41
|
+
Then edit `.env` with your configuration. See `.env.example` for all required variables.
|
|
45
42
|
|
|
46
43
|
4. **Set up the database:**
|
|
47
44
|
- Create a PostgreSQL database named `easy_lms`
|
|
@@ -119,6 +116,10 @@ npx prisma studio
|
|
|
119
116
|
- `npm run dev` — Start in development mode with hot reload
|
|
120
117
|
- `npm run build` — Compile TypeScript to JavaScript
|
|
121
118
|
- `npm start` — Start the compiled server
|
|
119
|
+
- `npm test` — Run tests with Vitest
|
|
120
|
+
- `npm run test:run` — Run tests once
|
|
121
|
+
- `npm run test:watch` — Run tests in watch mode
|
|
122
|
+
- `npm run test:coverage` — Run tests with coverage report
|
|
122
123
|
|
|
123
124
|
## Environment Variables
|
|
124
125
|
|
|
@@ -138,6 +139,32 @@ The server uses TypeScript and includes:
|
|
|
138
139
|
- **Prisma** for database operations
|
|
139
140
|
- **Express** middleware for CORS and logging
|
|
140
141
|
|
|
142
|
+
### Testing
|
|
143
|
+
|
|
144
|
+
Tests use a separate environment configuration:
|
|
145
|
+
|
|
146
|
+
1. **Set up test environment:**
|
|
147
|
+
```bash
|
|
148
|
+
cp .env.test.example .env.test
|
|
149
|
+
```
|
|
150
|
+
Update `.env.test` with your test database configuration.
|
|
151
|
+
|
|
152
|
+
2. **Create test database:**
|
|
153
|
+
```bash
|
|
154
|
+
createdb easy_lms_test
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
3. **Run tests:**
|
|
158
|
+
```bash
|
|
159
|
+
npm test
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The test environment:
|
|
163
|
+
- Uses a separate database (`easy_lms_test`)
|
|
164
|
+
- Runs on a different port (3002)
|
|
165
|
+
- Has minimal logging (error level only)
|
|
166
|
+
- Mocks external services (Google Cloud, Pusher, etc.)
|
|
167
|
+
|
|
141
168
|
## License
|
|
142
169
|
|
|
143
170
|
[MIT](LICENSE.txt)
|
package/dist/exportType.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportType.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"exportType.d.ts","sourceRoot":"/","sources":["exportType.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/exportType.js
CHANGED
|
@@ -3,4 +3,8 @@
|
|
|
3
3
|
* This is used to export the types for the server
|
|
4
4
|
* to the client via npmjs
|
|
5
5
|
*/
|
|
6
|
+
|
|
7
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a04570aa-7e76-52f1-b955-58b2dac7510a")}catch(e){}}();
|
|
6
8
|
export {};
|
|
9
|
+
//# sourceMappingURL=exportType.js.map
|
|
10
|
+
//# debugId=a04570aa-7e76-52f1-b955-58b2dac7510a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exportType.js","sources":["exportType.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Export types for the server\n * This is used to export the types for the server\n * to the client via npmjs\n */\n\nexport type { AppRouter } from \"./routers/_app.js\";\nexport type { RouterInputs } from \"./routers/_app.js\";\nexport type { RouterOutputs } from \"./routers/_app.js\";"],"names":[],"mappings":"AAAA;;;;GAIG","debug_id":"a04570aa-7e76-52f1-b955-58b2dac7510a"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import "./instrument.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAwBA,OAAO,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e28b4205-9ed2-5148-b94c-3326b3073261")}catch(e){}}();
|
|
1
3
|
import express from 'express';
|
|
2
4
|
import { createServer } from 'http';
|
|
3
5
|
import { Server } from 'socket.io';
|
|
4
6
|
import cors from 'cors';
|
|
5
|
-
import dotenv from 'dotenv';
|
|
6
7
|
import { createExpressMiddleware } from '@trpc/server/adapters/express';
|
|
7
8
|
import { appRouter } from './routers/_app.js';
|
|
8
9
|
import { createTRPCContext, createCallerFactory } from './trpc.js';
|
|
@@ -10,47 +11,50 @@ import { logger } from './utils/logger.js';
|
|
|
10
11
|
import { setupSocketHandlers } from './socket/handlers.js';
|
|
11
12
|
import { bucket } from './lib/googleCloudStorage.js';
|
|
12
13
|
import { prisma } from './lib/prisma.js';
|
|
13
|
-
|
|
14
|
+
import { pusher } from './lib/pusher.js';
|
|
15
|
+
import { connectRedis, disconnectRedis } from './lib/redis.js';
|
|
16
|
+
import { authLimiter, generalLimiter, helmetConfig, uploadLimiter } from './middleware/security.js';
|
|
17
|
+
import * as Sentry from "@sentry/node";
|
|
18
|
+
import { env } from './lib/config/env.js';
|
|
19
|
+
import compression from 'compression';
|
|
20
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
21
|
+
import "./instrument.js";
|
|
14
22
|
const app = express();
|
|
23
|
+
app.use(helmetConfig);
|
|
24
|
+
app.use(compression());
|
|
25
|
+
app.use(express.json());
|
|
26
|
+
app.use(express.urlencoded({ extended: true }));
|
|
27
|
+
app.use((req, res, next) => {
|
|
28
|
+
const requestId = uuidv4();
|
|
29
|
+
res.setHeader('X-Request-ID', requestId);
|
|
30
|
+
next();
|
|
31
|
+
});
|
|
32
|
+
const allowedOrigins = env.NODE_ENV === 'production'
|
|
33
|
+
? [
|
|
34
|
+
'https://www.studious.sh',
|
|
35
|
+
'https://studious.sh',
|
|
36
|
+
'https://dev.studious.sh',
|
|
37
|
+
'https://www.dev.studious.sh',
|
|
38
|
+
env.NEXT_PUBLIC_APP_URL,
|
|
39
|
+
'http://localhost:3000',
|
|
40
|
+
].filter(Boolean)
|
|
41
|
+
: [
|
|
42
|
+
'http://localhost:3000',
|
|
43
|
+
'http://localhost:3001',
|
|
44
|
+
'http://127.0.0.1:3000',
|
|
45
|
+
'http://127.0.0.1:3001',
|
|
46
|
+
env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
47
|
+
];
|
|
15
48
|
// CORS middleware
|
|
16
49
|
app.use(cors({
|
|
17
|
-
origin:
|
|
18
|
-
'http://localhost:3000', // Frontend development server
|
|
19
|
-
'http://localhost:3001', // Server port
|
|
20
|
-
'http://127.0.0.1:3000', // Alternative localhost
|
|
21
|
-
'http://127.0.0.1:3001', // Alternative localhost
|
|
22
|
-
'https://www.studious.sh', // Production frontend
|
|
23
|
-
'https://studious.sh', // Production frontend (without www)
|
|
24
|
-
process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
25
|
-
],
|
|
50
|
+
origin: allowedOrigins,
|
|
26
51
|
credentials: true,
|
|
27
52
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
|
28
53
|
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'x-user'],
|
|
29
|
-
|
|
54
|
+
preflightContinue: false, // Important: stop further handling of OPTIONS
|
|
55
|
+
optionsSuccessStatus: 204, // Recommended for modern browsers
|
|
30
56
|
}));
|
|
31
|
-
|
|
32
|
-
app.options('*', (req, res) => {
|
|
33
|
-
const allowedOrigins = [
|
|
34
|
-
'http://localhost:3000',
|
|
35
|
-
'http://localhost:3001',
|
|
36
|
-
'http://127.0.0.1:3000',
|
|
37
|
-
'http://127.0.0.1:3001',
|
|
38
|
-
'https://www.studious.sh', // Production frontend
|
|
39
|
-
'https://studious.sh', // Production frontend (without www)
|
|
40
|
-
process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
41
|
-
];
|
|
42
|
-
const origin = req.headers.origin;
|
|
43
|
-
if (origin && allowedOrigins.includes(origin)) {
|
|
44
|
-
res.header('Access-Control-Allow-Origin', origin);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
res.header('Access-Control-Allow-Origin', 'http://localhost:3000');
|
|
48
|
-
}
|
|
49
|
-
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
50
|
-
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With, x-user');
|
|
51
|
-
res.header('Access-Control-Allow-Credentials', 'true');
|
|
52
|
-
res.sendStatus(200);
|
|
53
|
-
});
|
|
57
|
+
app.use(generalLimiter);
|
|
54
58
|
// CORS debugging middleware
|
|
55
59
|
app.use((req, res, next) => {
|
|
56
60
|
if (req.method === 'OPTIONS' || req.path.includes('trpc')) {
|
|
@@ -77,10 +81,129 @@ app.use((req, res, next) => {
|
|
|
77
81
|
});
|
|
78
82
|
next();
|
|
79
83
|
});
|
|
84
|
+
// app.use("/panel", async (_, res) => {
|
|
85
|
+
// if (env.NODE_ENV !== "development") {
|
|
86
|
+
// return res.status(404).send("Not Found");
|
|
87
|
+
// }
|
|
88
|
+
// // Dynamically import renderTrpcPanel only in development
|
|
89
|
+
// const { renderTrpcPanel } = await import("trpc-ui");
|
|
90
|
+
// return res.send(
|
|
91
|
+
// renderTrpcPanel(appRouter, {
|
|
92
|
+
// url: "/trpc", // Base url of your trpc server
|
|
93
|
+
// meta: {
|
|
94
|
+
// title: "Studious Backend",
|
|
95
|
+
// description:
|
|
96
|
+
// "This is the backend for the Studious application.",
|
|
97
|
+
// },
|
|
98
|
+
// })
|
|
99
|
+
// );
|
|
100
|
+
// });
|
|
80
101
|
// Create HTTP server
|
|
81
102
|
const httpServer = createServer(app);
|
|
82
|
-
app.get('/health', (req, res) => {
|
|
83
|
-
|
|
103
|
+
app.get('/health', async (req, res) => {
|
|
104
|
+
try {
|
|
105
|
+
// Check database connectivity
|
|
106
|
+
await prisma.$queryRaw `SELECT 1`;
|
|
107
|
+
res.status(200).json({
|
|
108
|
+
status: 'OK',
|
|
109
|
+
timestamp: new Date().toISOString(),
|
|
110
|
+
uptime: process.uptime(),
|
|
111
|
+
database: 'connected'
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
res.status(503).json({
|
|
116
|
+
status: 'ERROR',
|
|
117
|
+
database: 'disconnected',
|
|
118
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
// Pusher channel auth (for private-* and presence-* channels)
|
|
123
|
+
// Token from: x-user header, or cookie (same-origin requests send cookies automatically)
|
|
124
|
+
app.post('/api/pusher/auth', async (req, res) => {
|
|
125
|
+
try {
|
|
126
|
+
let token = req.headers['x-user'];
|
|
127
|
+
if (!token && req.headers.cookie) {
|
|
128
|
+
const cookieName = env.PUSHER_AUTH_COOKIE_NAME || 'token';
|
|
129
|
+
const match = req.headers.cookie.match(new RegExp(`${cookieName}=([^;]+)`));
|
|
130
|
+
token = match?.[1]?.trim();
|
|
131
|
+
}
|
|
132
|
+
const { socket_id, channel_name } = req.body;
|
|
133
|
+
if (!socket_id || !channel_name) {
|
|
134
|
+
return res.status(400).json({ error: 'socket_id and channel_name required' });
|
|
135
|
+
}
|
|
136
|
+
if (!token) {
|
|
137
|
+
return res.status(401).json({ error: 'Authentication required' });
|
|
138
|
+
}
|
|
139
|
+
const user = await prisma.user.findFirst({
|
|
140
|
+
where: { sessions: { some: { id: token } } },
|
|
141
|
+
select: { id: true, username: true },
|
|
142
|
+
});
|
|
143
|
+
if (!user) {
|
|
144
|
+
return res.status(401).json({ error: 'Invalid or expired session' });
|
|
145
|
+
}
|
|
146
|
+
// Verify channel access for private-conversation-* channels
|
|
147
|
+
if (channel_name.startsWith('private-conversation-')) {
|
|
148
|
+
const conversationId = channel_name.replace('private-conversation-', '');
|
|
149
|
+
const member = await prisma.conversationMember.findFirst({
|
|
150
|
+
where: { conversationId, userId: user.id },
|
|
151
|
+
});
|
|
152
|
+
if (!member) {
|
|
153
|
+
return res.status(403).json({ error: 'Not a member of this conversation' });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (channel_name.startsWith('private-worksheet-')) {
|
|
157
|
+
const worksheetId = channel_name.replace('private-worksheet-', '');
|
|
158
|
+
const worksheet = await prisma.studentWorksheetResponse.findFirst({
|
|
159
|
+
where: { id: worksheetId, OR: [
|
|
160
|
+
{ studentId: user.id },
|
|
161
|
+
{ submission: { assignment: { class: { teachers: { some: { id: user.id } } } } } },
|
|
162
|
+
] },
|
|
163
|
+
});
|
|
164
|
+
if (!worksheet) {
|
|
165
|
+
return res.status(403).json({ error: 'No access to this worksheet' });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (channel_name.startsWith('private-teacher-')) {
|
|
169
|
+
const classId = channel_name.replace('private-teacher-', '');
|
|
170
|
+
const isTeacher = await prisma.class.findFirst({
|
|
171
|
+
where: { id: classId, teachers: { some: { id: user.id } } },
|
|
172
|
+
});
|
|
173
|
+
if (!isTeacher) {
|
|
174
|
+
return res.status(403).json({ error: 'Not a teacher of this class' });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Verify channel access for private-class-* channels
|
|
178
|
+
// if (channel_name.startsWith('private-class-')) {
|
|
179
|
+
// const classId = channel_name.replace('private-class-', '');
|
|
180
|
+
// const isMember = await prisma.class.findFirst({
|
|
181
|
+
// where: {
|
|
182
|
+
// id: classId,
|
|
183
|
+
// OR: [
|
|
184
|
+
// { students: { some: { id: user.id } } },
|
|
185
|
+
// { teachers: { some: { id: user.id } } },
|
|
186
|
+
// ],
|
|
187
|
+
// },
|
|
188
|
+
// });
|
|
189
|
+
// if (!isMember) {
|
|
190
|
+
// return res.status(403).json({ error: 'Not a member of this class' });
|
|
191
|
+
// }
|
|
192
|
+
// }
|
|
193
|
+
if (channel_name.startsWith('presence-')) {
|
|
194
|
+
const authResponse = pusher.authorizeChannel(socket_id, channel_name, {
|
|
195
|
+
user_id: user.id,
|
|
196
|
+
user_info: { username: user.username },
|
|
197
|
+
});
|
|
198
|
+
return res.json(authResponse);
|
|
199
|
+
}
|
|
200
|
+
const authResponse = pusher.authorizeChannel(socket_id, channel_name);
|
|
201
|
+
return res.json(authResponse);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
logger.error('Pusher auth error', { error });
|
|
205
|
+
return res.status(500).json({ error: 'Authentication failed' });
|
|
206
|
+
}
|
|
84
207
|
});
|
|
85
208
|
// Setup Socket.IO
|
|
86
209
|
const io = new Server(httpServer, {
|
|
@@ -92,7 +215,7 @@ const io = new Server(httpServer, {
|
|
|
92
215
|
'http://127.0.0.1:3001', // Alternative localhost
|
|
93
216
|
'https://www.studious.sh', // Production frontend
|
|
94
217
|
'https://studious.sh', // Production frontend (without www)
|
|
95
|
-
|
|
218
|
+
env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
96
219
|
],
|
|
97
220
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
|
98
221
|
credentials: true,
|
|
@@ -292,11 +415,13 @@ app.get('/api/files/:fileId', async (req, res) => {
|
|
|
292
415
|
res.status(500).json({ error: 'Internal server error' });
|
|
293
416
|
}
|
|
294
417
|
});
|
|
418
|
+
app.use('/trpc/auth.login', authLimiter);
|
|
419
|
+
app.use('/trpc/auth.register', authLimiter);
|
|
295
420
|
// File upload endpoint for secure file uploads (supports both POST and PUT)
|
|
296
|
-
app.post('/api/upload/:filePath', async (req, res) => {
|
|
421
|
+
app.post('/api/upload/:filePath', uploadLimiter, async (req, res) => {
|
|
297
422
|
handleFileUpload(req, res);
|
|
298
423
|
});
|
|
299
|
-
app.put('/api/upload/:filePath', async (req, res) => {
|
|
424
|
+
app.put('/api/upload/:filePath', uploadLimiter, async (req, res) => {
|
|
300
425
|
handleFileUpload(req, res);
|
|
301
426
|
});
|
|
302
427
|
function handleFileUpload(req, res) {
|
|
@@ -311,7 +436,7 @@ function handleFileUpload(req, res) {
|
|
|
311
436
|
'http://127.0.0.1:3001',
|
|
312
437
|
'https://www.studious.sh', // Production frontend
|
|
313
438
|
'https://studious.sh', // Production frontend (without www)
|
|
314
|
-
|
|
439
|
+
env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
315
440
|
];
|
|
316
441
|
if (origin && allowedOrigins.includes(origin)) {
|
|
317
442
|
res.header('Access-Control-Allow-Origin', origin);
|
|
@@ -361,19 +486,30 @@ app.use('/trpc', createExpressMiddleware({
|
|
|
361
486
|
return createTRPCContext({ req, res });
|
|
362
487
|
},
|
|
363
488
|
}));
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
489
|
+
// IMPORTANT: Sentry error handler must be added AFTER all other middleware and routes
|
|
490
|
+
// but BEFORE any other error handlers
|
|
491
|
+
Sentry.setupExpressErrorHandler(app);
|
|
492
|
+
// app.use(function onError(err, req, res, next) {
|
|
493
|
+
// // The error id is attached to `res.sentry` to be returned
|
|
494
|
+
// // and optionally displayed to the user for support.
|
|
495
|
+
// res.statusCode = 500;
|
|
496
|
+
// res.end(res.sentry + "\n");
|
|
497
|
+
// });
|
|
498
|
+
const PORT = env.PORT || 3001;
|
|
499
|
+
connectRedis().then(() => {
|
|
500
|
+
httpServer.listen(PORT, () => {
|
|
501
|
+
logger.info(`Server running on port ${PORT}`, {
|
|
502
|
+
port: PORT,
|
|
503
|
+
services: ['tRPC', 'Socket.IO', env.REDIS_URL ? 'Redis' : null].filter(Boolean),
|
|
504
|
+
});
|
|
369
505
|
});
|
|
370
506
|
});
|
|
371
507
|
// log all env variables
|
|
372
508
|
logger.info('Configurations', {
|
|
373
|
-
NODE_ENV:
|
|
374
|
-
PORT:
|
|
375
|
-
NEXT_PUBLIC_APP_URL:
|
|
376
|
-
LOG_MODE:
|
|
509
|
+
NODE_ENV: env.NODE_ENV,
|
|
510
|
+
PORT: env.PORT,
|
|
511
|
+
NEXT_PUBLIC_APP_URL: env.NEXT_PUBLIC_APP_URL,
|
|
512
|
+
LOG_MODE: env.LOG_MODE,
|
|
377
513
|
});
|
|
378
514
|
// Log CORS configuration
|
|
379
515
|
logger.info('CORS Configuration', {
|
|
@@ -382,6 +518,31 @@ logger.info('CORS Configuration', {
|
|
|
382
518
|
'http://localhost:3001',
|
|
383
519
|
'http://127.0.0.1:3000',
|
|
384
520
|
'http://127.0.0.1:3001',
|
|
385
|
-
|
|
521
|
+
env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
386
522
|
]
|
|
387
523
|
});
|
|
524
|
+
const gracefulShutdown = (signal) => {
|
|
525
|
+
logger.info(`Received ${signal}, shutting down gracefully`);
|
|
526
|
+
httpServer.close(() => {
|
|
527
|
+
logger.info('HTTP server closed');
|
|
528
|
+
io.close(() => {
|
|
529
|
+
logger.info('Socket.IO server closed');
|
|
530
|
+
disconnectRedis().then(() => prisma.$disconnect().then(() => {
|
|
531
|
+
logger.info('Database connections closed');
|
|
532
|
+
process.exit(0);
|
|
533
|
+
}).catch((err) => {
|
|
534
|
+
logger.error('Error disconnecting from database', { error: err });
|
|
535
|
+
process.exit(1);
|
|
536
|
+
}));
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
// Force shutdown after 10 seconds
|
|
540
|
+
setTimeout(() => {
|
|
541
|
+
logger.error('Forced shutdown after timeout');
|
|
542
|
+
process.exit(1);
|
|
543
|
+
}, 10000);
|
|
544
|
+
};
|
|
545
|
+
process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
|
|
546
|
+
process.on('SIGINT', () => gracefulShutdown('SIGINT'));
|
|
547
|
+
//# sourceMappingURL=index.js.map
|
|
548
|
+
//# debugId=e28b4205-9ed2-5148-b94c-3326b3073261
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["index.ts"],"sourceRoot":"/","sourcesContent":["import express from 'express';\nimport type { Request, Response } from 'express';\nimport { createServer } from 'http';\nimport { Server } from 'socket.io';\nimport cors from 'cors';\nimport dotenv from 'dotenv';\nimport { createExpressMiddleware } from '@trpc/server/adapters/express';\nimport { appRouter } from './routers/_app.js';\nimport { createTRPCContext, createCallerFactory } from './trpc.js';\nimport { logger } from './utils/logger.js';\nimport { setupSocketHandlers } from './socket/handlers.js';\nimport { bucket } from './lib/googleCloudStorage.js';\nimport { prisma } from './lib/prisma.js';\nimport { pusher } from './lib/pusher.js';\nimport { connectRedis, disconnectRedis } from './lib/redis.js';\n\nimport { authLimiter, generalLimiter, helmetConfig, uploadLimiter } from './middleware/security.js';\n\nimport * as Sentry from \"@sentry/node\";\nimport { env } from './lib/config/env.js';\nimport compression from 'compression';\nimport { v4 as uuidv4 } from 'uuid';\n\n\nimport \"./instrument.js\";\nimport { openAIClient } from './utils/inference.js';\n\nconst app = express();\n\napp.use(helmetConfig);\napp.use(compression());\napp.use(express.json());\napp.use(express.urlencoded({ extended: true }));\n\napp.use((req, res, next) => {\n const requestId = uuidv4();\n res.setHeader('X-Request-ID', requestId);\n next();\n});\n\nconst allowedOrigins = env.NODE_ENV === 'production'\n? [\n 'https://www.studious.sh',\n 'https://studious.sh',\n 'https://dev.studious.sh',\n 'https://www.dev.studious.sh',\n env.NEXT_PUBLIC_APP_URL,\n 'http://localhost:3000',\n\n ].filter(Boolean)\n: [\n 'http://localhost:3000',\n 'http://localhost:3001',\n 'http://127.0.0.1:3000',\n 'http://127.0.0.1:3001',\n\n env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'\n ];\n\n// CORS middleware\napp.use(cors({\n origin: allowedOrigins,\n credentials: true,\n methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],\n allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'x-user'],\n preflightContinue: false, // Important: stop further handling of OPTIONS\n optionsSuccessStatus: 204, // Recommended for modern browsers\n\n}));\n\napp.use(generalLimiter);\n\n// CORS debugging middleware\napp.use((req, res, next) => {\n if (req.method === 'OPTIONS' || req.path.includes('trpc')) {\n logger.info('CORS Request', {\n method: req.method,\n path: req.path,\n origin: req.headers.origin,\n userAgent: req.headers['user-agent']\n });\n }\n next();\n});\n\n// Response time logging middleware\napp.use((req, res, next) => {\n const start = Date.now();\n res.on('finish', () => {\n const duration = Date.now() - start;\n logger.info('Request completed', {\n method: req.method,\n path: req.path,\n statusCode: res.statusCode,\n duration: `${duration}ms`\n });\n });\n next();\n});\n\n// app.use(\"/panel\", async (_, res) => {\n// if (env.NODE_ENV !== \"development\") {\n// return res.status(404).send(\"Not Found\");\n// }\n\n// // Dynamically import renderTrpcPanel only in development\n// const { renderTrpcPanel } = await import(\"trpc-ui\");\n\n// return res.send(\n// renderTrpcPanel(appRouter, {\n// url: \"/trpc\", // Base url of your trpc server\n// meta: {\n// title: \"Studious Backend\",\n// description:\n// \"This is the backend for the Studious application.\",\n// },\n// })\n// );\n// });\n\n\n// Create HTTP server\nconst httpServer = createServer(app);\n\napp.get('/health', async (req, res) => {\n\n try {\n // Check database connectivity\n await prisma.$queryRaw`SELECT 1`;\n \n res.status(200).json({ \n status: 'OK',\n timestamp: new Date().toISOString(),\n uptime: process.uptime(),\n database: 'connected'\n });\n } catch (error) {\n res.status(503).json({ \n status: 'ERROR',\n database: 'disconnected',\n error: error instanceof Error ? error.message : 'Unknown error'\n });\n }\n});\n\n// Pusher channel auth (for private-* and presence-* channels)\n// Token from: x-user header, or cookie (same-origin requests send cookies automatically)\napp.post('/api/pusher/auth', async (req, res) => {\n try {\n let token = req.headers['x-user'] as string | undefined;\n if (!token && req.headers.cookie) {\n const cookieName = env.PUSHER_AUTH_COOKIE_NAME || 'token';\n const match = req.headers.cookie.match(new RegExp(`${cookieName}=([^;]+)`));\n token = match?.[1]?.trim();\n }\n const { socket_id, channel_name } = req.body as { socket_id?: string; channel_name?: string };\n\n if (!socket_id || !channel_name) {\n return res.status(400).json({ error: 'socket_id and channel_name required' });\n }\n\n if (!token) {\n return res.status(401).json({ error: 'Authentication required' });\n }\n\n const user = await prisma.user.findFirst({\n where: { sessions: { some: { id: token } } },\n select: { id: true, username: true },\n });\n\n if (!user) {\n return res.status(401).json({ error: 'Invalid or expired session' });\n }\n\n // Verify channel access for private-conversation-* channels\n if (channel_name.startsWith('private-conversation-')) {\n const conversationId = channel_name.replace('private-conversation-', '');\n const member = await prisma.conversationMember.findFirst({\n where: { conversationId, userId: user.id },\n });\n \n if (!member) {\n return res.status(403).json({ error: 'Not a member of this conversation' });\n }\n }\n\n if (channel_name.startsWith('private-worksheet-')) {\n const worksheetId = channel_name.replace('private-worksheet-', '');\n const worksheet = await prisma.studentWorksheetResponse.findFirst({\n where: { id: worksheetId, OR: [\n { studentId: user.id },\n { submission: { assignment: { class: { teachers: { some: { id: user.id } } } } } },\n ] },\n });\n if (!worksheet) {\n return res.status(403).json({ error: 'No access to this worksheet' });\n }\n }\n\n if (channel_name.startsWith('private-teacher-')) {\n const classId = channel_name.replace('private-teacher-', '');\n const isTeacher = await prisma.class.findFirst({\n where: { id: classId, teachers: { some: { id: user.id } } },\n });\n if (!isTeacher) {\n return res.status(403).json({ error: 'Not a teacher of this class' });\n }\n }\n\n // Verify channel access for private-class-* channels\n // if (channel_name.startsWith('private-class-')) {\n // const classId = channel_name.replace('private-class-', '');\n // const isMember = await prisma.class.findFirst({\n // where: {\n // id: classId,\n // OR: [\n // { students: { some: { id: user.id } } },\n // { teachers: { some: { id: user.id } } },\n // ],\n // },\n // });\n // if (!isMember) {\n // return res.status(403).json({ error: 'Not a member of this class' });\n // }\n // }\n\n if (channel_name.startsWith('presence-')) {\n const authResponse = pusher.authorizeChannel(socket_id, channel_name, {\n user_id: user.id,\n user_info: { username: user.username },\n });\n return res.json(authResponse);\n }\n\n const authResponse = pusher.authorizeChannel(socket_id, channel_name);\n return res.json(authResponse);\n } catch (error) {\n logger.error('Pusher auth error', { error });\n return res.status(500).json({ error: 'Authentication failed' });\n }\n});\n\n// Setup Socket.IO\nconst io = new Server(httpServer, {\n cors: {\n origin: [\n 'http://localhost:3000', // Frontend development server\n 'http://localhost:3001', // Server port\n 'http://127.0.0.1:3000', // Alternative localhost\n 'http://127.0.0.1:3001', // Alternative localhost\n 'https://www.studious.sh', // Production frontend\n 'https://studious.sh', // Production frontend (without www)\n env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'\n ],\n methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],\n credentials: true,\n allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'Access-Control-Allow-Origin', 'x-user']\n },\n transports: ['websocket', 'polling'],\n pingTimeout: 60000,\n pingInterval: 25000,\n connectTimeout: 45000,\n path: '/socket.io/',\n allowEIO3: true\n});\n\n// Add server-level logging\nio.engine.on('connection_error', (err: Error) => {\n logger.error('Socket connection error', { error: err.message });\n});\n\n// Setup socket handlers\nsetupSocketHandlers(io);\n\n// File serving endpoint for secure file access\napp.get('/api/files/:fileId', async (req, res) => {\n try {\n const fileId = decodeURIComponent(req.params.fileId);\n // console.log('File request:', { fileId, originalPath: req.params.fileId });\n \n // Get user from request headers\n const userHeader = req.headers['x-user'];\n if (!userHeader) {\n return res.status(401).json({ error: 'Authentication required' });\n }\n\n const token = typeof userHeader === 'string' ? userHeader : userHeader[0];\n\n // Find user by session token\n const user = await prisma.user.findFirst({\n where: {\n sessions: {\n some: {\n id: token\n }\n }\n },\n select: {\n id: true,\n username: true,\n }\n });\n\n if (!user) {\n return res.status(401).json({ error: 'Invalid or expired session' });\n }\n\n // Find file in database by path\n const fileRecord = await prisma.file.findFirst({\n where: { id: fileId },\n include: {\n user: true,\n assignment: {\n include: {\n class: {\n include: {\n students: true,\n teachers: true\n }\n }\n }\n },\n submission: {\n include: {\n student: true,\n assignment: {\n include: {\n class: {\n include: {\n teachers: true\n }\n }\n }\n }\n }\n },\n annotations: {\n include: {\n student: true,\n assignment: {\n include: {\n class: {\n include: {\n teachers: true\n }\n }\n }\n }\n }\n },\n folder: {\n include: {\n class: {\n include: {\n students: true,\n teachers: true\n }\n }\n }\n },\n classDraft: {\n include: {\n students: true,\n teachers: true\n }\n }\n }\n });\n\n if (!fileRecord) {\n return res.status(404).json({ error: 'File not found in database' });\n }\n\n // Check if user has permission to access this file\n let hasPermission = false;\n\n // Check if user created the file\n if (fileRecord.userId === user.id) {\n hasPermission = true;\n }\n\n // Check if file is related to a class where user is a member\n if (!hasPermission) {\n // Check assignment files\n if (fileRecord.assignment?.class) {\n const classData = fileRecord.assignment.class;\n const isStudent = classData.students.some(student => student.id === user.id);\n const isTeacher = classData.teachers.some(teacher => teacher.id === user.id);\n if (isStudent || isTeacher) {\n hasPermission = true;\n }\n }\n\n if (!hasPermission && fileRecord.annotations) {\n const annotation = fileRecord.annotations;\n if (annotation.studentId === user.id) {\n hasPermission = true;\n } else if (annotation.assignment?.class?.teachers.some(teacher => teacher.id === user.id)) {\n hasPermission = true;\n }\n }\n\n // Check submission files (student can access their own submissions, teachers can access all submissions in their class)\n if (!hasPermission && fileRecord.submission) {\n const submission = fileRecord.submission;\n if (submission.studentId === user.id) {\n hasPermission = true; // Student accessing their own submission\n } else if (submission.assignment?.class?.teachers.some(teacher => teacher.id === user.id)) {\n hasPermission = true; // Teacher accessing submission in their class\n }\n }\n\n // Check folder files\n if (!hasPermission && fileRecord.folder?.class) {\n const classData = fileRecord.folder.class;\n const isStudent = classData.students.some(student => student.id === user.id);\n const isTeacher = classData.teachers.some(teacher => teacher.id === user.id);\n if (isStudent || isTeacher) {\n hasPermission = true;\n }\n }\n\n // Check class draft files\n if (!hasPermission && fileRecord.classDraft) {\n const classData = fileRecord.classDraft;\n const isStudent = classData.students.some(student => student.id === user.id);\n const isTeacher = classData.teachers.some(teacher => teacher.id === user.id);\n if (isStudent || isTeacher) {\n hasPermission = true;\n }\n }\n }\n\n if (!hasPermission) {\n return res.status(403).json({ error: 'Access denied - insufficient permissions' });\n }\n \n const filePath = fileRecord.path;\n \n // Get file from Google Cloud Storage\n const file = bucket.file(filePath);\n const [exists] = await file.exists();\n \n if (!exists) {\n return res.status(404).json({ error: 'File not found in storage', filePath });\n }\n \n // Get file metadata\n const [metadata] = await file.getMetadata();\n \n // Set appropriate headers\n res.set({\n 'Content-Type': metadata.contentType || 'application/octet-stream',\n 'Content-Length': metadata.size,\n 'Cache-Control': 'public, max-age=31536000', // 1 year cache\n 'ETag': metadata.etag,\n });\n \n // Stream file to response\n const stream = file.createReadStream();\n stream.pipe(res);\n \n stream.on('error', (error) => {\n logger.error('Error streaming file:', {error});\n if (!res.headersSent) {\n res.status(500).json({ error: 'Error streaming file' });\n }\n });\n \n } catch (error) {\n logger.error('Error serving file:', {error});\n res.status(500).json({ error: 'Internal server error' });\n }\n});\n\napp.use('/trpc/auth.login', authLimiter);\napp.use('/trpc/auth.register', authLimiter);\n\n// File upload endpoint for secure file uploads (supports both POST and PUT)\napp.post('/api/upload/:filePath', uploadLimiter, async (req, res) => {\n handleFileUpload(req, res);\n});\n\napp.put('/api/upload/:filePath', uploadLimiter, async (req, res) => {\n handleFileUpload(req, res);\n});\n\nfunction handleFileUpload(req: any, res: any) {\n try {\n const filePath = decodeURIComponent(req.params.filePath);\n \n // Set CORS headers for upload endpoint\n const origin = req.headers.origin;\n const allowedOrigins = [\n 'http://localhost:3000',\n 'http://localhost:3001', \n 'http://127.0.0.1:3000',\n 'http://127.0.0.1:3001',\n 'https://www.studious.sh', // Production frontend\n 'https://studious.sh', // Production frontend (without www)\n env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'\n ];\n \n if (origin && allowedOrigins.includes(origin)) {\n res.header('Access-Control-Allow-Origin', origin);\n } else {\n res.header('Access-Control-Allow-Origin', 'http://localhost:3000');\n }\n \n res.header('Access-Control-Allow-Credentials', 'true');\n \n // Get content type from headers\n const contentType = req.headers['content-type'] || 'application/octet-stream';\n \n // Create a new file in the bucket\n const file = bucket.file(filePath);\n \n // Create a write stream to Google Cloud Storage\n const writeStream = file.createWriteStream({\n metadata: {\n contentType,\n },\n });\n \n // Handle stream events\n writeStream.on('error', (error) => {\n logger.error('Error uploading file:', {error});\n if (!res.headersSent) {\n res.status(500).json({ error: 'Error uploading file' });\n }\n });\n \n writeStream.on('finish', () => {\n res.status(200).json({ \n success: true, \n filePath,\n message: 'File uploaded successfully' \n });\n });\n \n // Pipe the request body to the write stream\n req.pipe(writeStream);\n \n } catch (error) {\n logger.error('Error handling file upload:', {error});\n res.status(500).json({ error: 'Internal server error' });\n }\n}\n\n// Create caller\nconst createCaller = createCallerFactory(appRouter);\n\n// Setup tRPC middleware\napp.use(\n '/trpc',\n createExpressMiddleware({\n router: appRouter,\n createContext: async ({ req, res }: { req: Request; res: Response }) => {\n return createTRPCContext({ req, res });\n },\n })\n);\n\n// IMPORTANT: Sentry error handler must be added AFTER all other middleware and routes\n// but BEFORE any other error handlers\nSentry.setupExpressErrorHandler(app);\n\n// app.use(function onError(err, req, res, next) {\n// // The error id is attached to `res.sentry` to be returned\n// // and optionally displayed to the user for support.\n// res.statusCode = 500;\n// res.end(res.sentry + \"\\n\");\n// });\n\n\nconst PORT = env.PORT || 3001;\n\nconnectRedis().then(() => {\n httpServer.listen(PORT, () => {\n logger.info(`Server running on port ${PORT}`, {\n port: PORT,\n services: ['tRPC', 'Socket.IO', env.REDIS_URL ? 'Redis' : null].filter(Boolean),\n });\n });\n}); \n\n// log all env variables\nlogger.info('Configurations', {\n NODE_ENV: env.NODE_ENV,\n PORT: env.PORT,\n NEXT_PUBLIC_APP_URL: env.NEXT_PUBLIC_APP_URL,\n LOG_MODE: env.LOG_MODE,\n});\n\n// Log CORS configuration\nlogger.info('CORS Configuration', {\n allowedOrigins: [\n 'http://localhost:3000',\n 'http://localhost:3001', \n 'http://127.0.0.1:3000',\n 'http://127.0.0.1:3001',\n env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'\n ]\n});\n\nconst gracefulShutdown = (signal: string) => {\n logger.info(`Received ${signal}, shutting down gracefully`);\n \n httpServer.close(() => {\n logger.info('HTTP server closed');\n \n io.close(() => {\n logger.info('Socket.IO server closed');\n\n disconnectRedis().then(() =>\n prisma.$disconnect().then(() => {\n logger.info('Database connections closed');\n process.exit(0);\n }).catch((err) => {\n logger.error('Error disconnecting from database', { error: err });\n process.exit(1);\n })\n );\n });\n });\n \n // Force shutdown after 10 seconds\n setTimeout(() => {\n logger.error('Forced shutdown after timeout');\n process.exit(1);\n }, 10000);\n};\n\nprocess.on('SIGTERM', () => gracefulShutdown('SIGTERM'));\nprocess.on('SIGINT', () => gracefulShutdown('SIGINT'));"],"names":[],"mappings":";;AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;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AClB,CAAC,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,kCAAkC;IAClC,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC,CAAC;AAEF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;AACzD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC","debug_id":"e28b4205-9ed2-5148-b94c-3326b3073261"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrument.d.ts","sourceRoot":"/","sources":["instrument.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="eedba78e-175f-5c0b-809f-3af467929bd2")}catch(e){}}();
|
|
3
|
+
import * as Sentry from "@sentry/node";
|
|
4
|
+
import { env } from "./lib/config/env.js";
|
|
5
|
+
// Only initialize Sentry in non-test environments
|
|
6
|
+
if (env.NODE_ENV !== 'test') {
|
|
7
|
+
Sentry.init({
|
|
8
|
+
dsn: env.SENTRY_DSN,
|
|
9
|
+
environment: env.NODE_ENV || 'development',
|
|
10
|
+
// Setting this option to true will send default PII data to Sentry.
|
|
11
|
+
// For example, automatic IP address collection on events
|
|
12
|
+
sendDefaultPii: true,
|
|
13
|
+
// @todo: disable in test environment
|
|
14
|
+
enabled: true, // Explicitly disable in test environment
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=instrument.js.map
|
|
18
|
+
//# debugId=eedba78e-175f-5c0b-809f-3af467929bd2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrument.js","sources":["instrument.ts"],"sourceRoot":"/","sourcesContent":["import * as Sentry from \"@sentry/node\";\nimport { env } from \"./lib/config/env.js\";\n\n// Only initialize Sentry in non-test environments\nif (env.NODE_ENV !== 'test') {\n Sentry.init({\n dsn: env.SENTRY_DSN,\n environment: env.NODE_ENV || 'development',\n // Setting this option to true will send default PII data to Sentry.\n // For example, automatic IP address collection on events\n sendDefaultPii: true,\n // @todo: disable in test environment\n enabled: true, // Explicitly disable in test environment\n });\n}\n"],"names":[],"mappings":";;AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,kDAAkD;AAClD,IAAI,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;IAC5B,MAAM,CAAC,IAAI,CAAC;QACV,GAAG,EAAE,GAAG,CAAC,UAAU;QACnB,WAAW,EAAE,GAAG,CAAC,QAAQ,IAAI,aAAa;QAC1C,oEAAoE;QACpE,yDAAyD;QACzD,cAAc,EAAE,IAAI;QACpB,qCAAqC;QACrC,OAAO,EAAE,IAAI,EAAE,yCAAyC;KACzD,CAAC,CAAC;AACL,CAAC","debug_id":"eedba78e-175f-5c0b-809f-3af467929bd2"}
|