@studious-lms/server 1.2.44 → 1.2.46
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/.env.example +45 -0
- package/.env.test.example +37 -0
- package/README.md +34 -7
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +12110 -0
- package/coverage/coverage-final.json +44 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +221 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/server/index.html +116 -0
- package/coverage/server/src/exportType.ts.html +109 -0
- package/coverage/server/src/index.html +161 -0
- package/coverage/server/src/index.ts.html +1702 -0
- package/coverage/server/src/instrument.ts.html +130 -0
- package/coverage/server/src/lib/config/env.ts.html +448 -0
- package/coverage/server/src/lib/config/index.html +116 -0
- package/coverage/server/src/lib/fileUpload.ts.html +1138 -0
- package/coverage/server/src/lib/googleCloudStorage.ts.html +334 -0
- package/coverage/server/src/lib/index.html +206 -0
- package/coverage/server/src/lib/jsonConversion.ts.html +2323 -0
- package/coverage/server/src/lib/jsonStyles.ts.html +193 -0
- package/coverage/server/src/lib/notificationHandler.ts.html +193 -0
- package/coverage/server/src/lib/pusher.ts.html +121 -0
- package/coverage/server/src/lib/thumbnailGenerator.ts.html +592 -0
- package/coverage/server/src/middleware/auth.ts.html +646 -0
- package/coverage/server/src/middleware/index.html +146 -0
- package/coverage/server/src/middleware/logging.ts.html +244 -0
- package/coverage/server/src/middleware/security.ts.html +271 -0
- package/coverage/server/src/routers/_app.ts.html +232 -0
- package/coverage/server/src/routers/agenda.ts.html +319 -0
- package/coverage/server/src/routers/announcement.ts.html +3481 -0
- package/coverage/server/src/routers/assignment.ts.html +7633 -0
- package/coverage/server/src/routers/attendance.ts.html +1030 -0
- package/coverage/server/src/routers/auth.ts.html +1081 -0
- package/coverage/server/src/routers/class.ts.html +3535 -0
- package/coverage/server/src/routers/comment.ts.html +991 -0
- package/coverage/server/src/routers/conversation.ts.html +982 -0
- package/coverage/server/src/routers/event.ts.html +1609 -0
- package/coverage/server/src/routers/file.ts.html +1144 -0
- package/coverage/server/src/routers/folder.ts.html +2797 -0
- package/coverage/server/src/routers/index.html +386 -0
- package/coverage/server/src/routers/labChat.ts.html +3073 -0
- package/coverage/server/src/routers/marketing.ts.html +340 -0
- package/coverage/server/src/routers/message.ts.html +1912 -0
- package/coverage/server/src/routers/notifications.ts.html +364 -0
- package/coverage/server/src/routers/section.ts.html +1120 -0
- package/coverage/server/src/routers/user.ts.html +862 -0
- package/coverage/server/src/routers/worksheet.ts.html +1729 -0
- package/coverage/server/src/trpc.ts.html +397 -0
- package/coverage/server/src/types/index.html +116 -0
- package/coverage/server/src/types/trpc.ts.html +127 -0
- package/coverage/server/src/utils/aiUser.ts.html +280 -0
- package/coverage/server/src/utils/email.ts.html +121 -0
- package/coverage/server/src/utils/generateInviteCode.ts.html +106 -0
- package/coverage/server/src/utils/index.html +206 -0
- package/coverage/server/src/utils/inference.ts.html +709 -0
- package/coverage/server/src/utils/logger.ts.html +664 -0
- package/coverage/server/src/utils/prismaErrorHandler.ts.html +907 -0
- package/coverage/server/src/utils/prismaWrapper.ts.html +355 -0
- package/coverage/server/vitest.config.ts.html +196 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +83 -52
- package/dist/index.js.map +1 -1
- package/dist/instrument.js +15 -8
- package/dist/instrument.js.map +1 -1
- package/dist/lib/config/env.d.ts +169 -0
- package/dist/lib/config/env.d.ts.map +1 -0
- package/dist/lib/config/env.js +115 -0
- package/dist/lib/config/env.js.map +1 -0
- package/dist/lib/fileUpload.d.ts.map +1 -1
- package/dist/lib/fileUpload.js +5 -4
- package/dist/lib/fileUpload.js.map +1 -1
- package/dist/lib/googleCloudStorage.d.ts.map +1 -1
- package/dist/lib/googleCloudStorage.js +7 -8
- package/dist/lib/googleCloudStorage.js.map +1 -1
- package/dist/lib/jsonConversion.d.ts.map +1 -1
- package/dist/lib/jsonConversion.js +14 -16
- package/dist/lib/jsonConversion.js.map +1 -1
- package/dist/lib/notificationHandler.d.ts +2 -2
- package/dist/lib/prisma.d.ts +2 -2
- package/dist/lib/prisma.d.ts.map +1 -1
- package/dist/lib/prisma.js +22 -3
- package/dist/lib/prisma.js.map +1 -1
- package/dist/lib/pusher.d.ts.map +1 -1
- package/dist/lib/pusher.js +8 -7
- package/dist/lib/pusher.js.map +1 -1
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +6 -5
- package/dist/middleware/auth.js.map +1 -1
- 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/routers/_app.d.ts +304 -98
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/_app.js +4 -2
- package/dist/routers/_app.js.map +1 -1
- package/dist/routers/agenda.d.ts.map +1 -1
- package/dist/routers/agenda.js +12 -9
- package/dist/routers/agenda.js.map +1 -1
- package/dist/routers/announcement.d.ts +8 -0
- package/dist/routers/announcement.d.ts.map +1 -1
- package/dist/routers/announcement.js +6 -4
- package/dist/routers/announcement.js.map +1 -1
- package/dist/routers/assignment.d.ts +7 -4
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +35 -18
- package/dist/routers/assignment.js.map +1 -1
- package/dist/routers/attendance.d.ts +1 -0
- package/dist/routers/attendance.d.ts.map +1 -1
- package/dist/routers/attendance.js +4 -4
- package/dist/routers/attendance.js.map +1 -1
- package/dist/routers/auth.d.ts +20 -0
- package/dist/routers/auth.d.ts.map +1 -1
- package/dist/routers/auth.js +132 -15
- package/dist/routers/auth.js.map +1 -1
- package/dist/routers/class.d.ts +10 -0
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/class.js +49 -5
- package/dist/routers/class.js.map +1 -1
- package/dist/routers/comment.d.ts +7 -0
- package/dist/routers/comment.d.ts.map +1 -1
- package/dist/routers/comment.js +9 -2
- package/dist/routers/comment.js.map +1 -1
- package/dist/routers/conversation.d.ts +1 -0
- package/dist/routers/conversation.d.ts.map +1 -1
- package/dist/routers/conversation.js +46 -31
- package/dist/routers/conversation.js.map +1 -1
- package/dist/routers/file.d.ts.map +1 -1
- package/dist/routers/file.js +30 -7
- package/dist/routers/file.js.map +1 -1
- package/dist/routers/labChat.d.ts +1 -0
- package/dist/routers/labChat.d.ts.map +1 -1
- package/dist/routers/labChat.js +2 -3
- package/dist/routers/labChat.js.map +1 -1
- package/dist/routers/marketing.d.ts +1 -1
- package/dist/routers/newtonChat.d.ts +55 -0
- package/dist/routers/newtonChat.d.ts.map +1 -0
- package/dist/routers/newtonChat.js +438 -0
- package/dist/routers/newtonChat.js.map +1 -0
- package/dist/routers/notifications.d.ts +4 -4
- package/dist/routers/section.d.ts +9 -4
- package/dist/routers/section.d.ts.map +1 -1
- package/dist/routers/section.js +8 -8
- package/dist/routers/section.js.map +1 -1
- package/dist/routers/user.d.ts.map +1 -1
- package/dist/routers/user.js +5 -4
- package/dist/routers/user.js.map +1 -1
- package/dist/routers/worksheet.d.ts +30 -36
- package/dist/routers/worksheet.d.ts.map +1 -1
- package/dist/routers/worksheet.js +11 -33
- package/dist/routers/worksheet.js.map +1 -1
- package/dist/seedDatabase.d.ts +1 -1
- package/dist/seedDatabase.js +275 -284
- package/dist/seedDatabase.js.map +1 -1
- package/dist/server/pipelines/aiLabChat.d.ts +10 -0
- package/dist/server/pipelines/aiLabChat.d.ts.map +1 -0
- package/dist/server/pipelines/aiLabChat.js +83 -0
- package/dist/server/pipelines/aiLabChat.js.map +1 -0
- package/dist/server/pipelines/gradeWorksheet.d.ts +2 -0
- package/dist/server/pipelines/gradeWorksheet.d.ts.map +1 -0
- package/dist/server/pipelines/gradeWorksheet.js +138 -0
- package/dist/server/pipelines/gradeWorksheet.js.map +1 -0
- package/dist/trpc.d.ts.map +1 -1
- package/dist/trpc.js +2 -2
- package/dist/trpc.js.map +1 -1
- package/dist/utils/email.d.ts +9 -1
- package/dist/utils/email.d.ts.map +1 -1
- package/dist/utils/email.js +20 -5
- package/dist/utils/email.js.map +1 -1
- package/dist/utils/inference.d.ts +3 -0
- package/dist/utils/inference.d.ts.map +1 -1
- package/dist/utils/inference.js +41 -7
- package/dist/utils/inference.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +3 -3
- package/dist/utils/logger.js.map +1 -1
- package/docker-compose.yml +14 -0
- package/package.json +13 -4
- package/prisma/schema.prisma +32 -5
- package/scripts/test-pre-push.ts +14 -0
- package/src/index.ts +98 -54
- package/src/instrument.ts +13 -6
- package/src/lib/config/env.ts +126 -0
- package/src/lib/fileUpload.ts +3 -2
- package/src/lib/googleCloudStorage.ts +6 -6
- package/src/lib/jsonConversion.ts +12 -14
- package/src/lib/prisma.ts +23 -2
- package/src/lib/pusher.ts +6 -5
- package/src/middleware/auth.ts +4 -3
- package/src/middleware/security.ts +80 -0
- package/src/routers/_app.ts +2 -0
- package/src/routers/agenda.ts +10 -7
- package/src/routers/announcement.ts +4 -2
- package/src/routers/assignment.ts +58 -40
- package/src/routers/attendance.ts +2 -2
- package/src/routers/auth.ts +143 -14
- package/src/routers/class.ts +52 -3
- package/src/routers/comment.ts +7 -0
- package/src/routers/conversation.ts +49 -29
- package/src/routers/file.ts +29 -5
- package/src/routers/labChat.ts +0 -1
- package/src/routers/newtonChat.ts +520 -0
- package/src/routers/section.ts +6 -6
- package/src/routers/user.ts +3 -2
- package/src/routers/worksheet.ts +9 -37
- package/src/seedDatabase.ts +290 -283
- package/src/server/pipelines/aiLabChat.ts +92 -0
- package/src/server/pipelines/gradeWorksheet.ts +152 -0
- package/src/trpc.ts +2 -0
- package/src/utils/email.ts +30 -3
- package/src/utils/inference.ts +50 -5
- package/src/utils/logger.ts +2 -1
- package/tests/announcement.test.ts +164 -0
- package/tests/assignment.test.ts +296 -0
- package/tests/attendance.test.ts +168 -0
- package/tests/auth.test.ts +33 -10
- package/tests/class.test.ts +34 -9
- package/tests/event.test.ts +228 -0
- package/tests/section.test.ts +216 -0
- package/tests/setup.ts +70 -16
- package/tests/user.test.ts +158 -0
- package/vitest.config.ts +26 -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 -483
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
var addSorting = (function() {
|
|
3
|
+
'use strict';
|
|
4
|
+
var cols,
|
|
5
|
+
currentSort = {
|
|
6
|
+
index: 0,
|
|
7
|
+
desc: false
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// returns the summary table element
|
|
11
|
+
function getTable() {
|
|
12
|
+
return document.querySelector('.coverage-summary');
|
|
13
|
+
}
|
|
14
|
+
// returns the thead element of the summary table
|
|
15
|
+
function getTableHeader() {
|
|
16
|
+
return getTable().querySelector('thead tr');
|
|
17
|
+
}
|
|
18
|
+
// returns the tbody element of the summary table
|
|
19
|
+
function getTableBody() {
|
|
20
|
+
return getTable().querySelector('tbody');
|
|
21
|
+
}
|
|
22
|
+
// returns the th element for nth column
|
|
23
|
+
function getNthColumn(n) {
|
|
24
|
+
return getTableHeader().querySelectorAll('th')[n];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function onFilterInput() {
|
|
28
|
+
const searchValue = document.getElementById('fileSearch').value;
|
|
29
|
+
const rows = document.getElementsByTagName('tbody')[0].children;
|
|
30
|
+
|
|
31
|
+
// Try to create a RegExp from the searchValue. If it fails (invalid regex),
|
|
32
|
+
// it will be treated as a plain text search
|
|
33
|
+
let searchRegex;
|
|
34
|
+
try {
|
|
35
|
+
searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive
|
|
36
|
+
} catch (error) {
|
|
37
|
+
searchRegex = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
for (let i = 0; i < rows.length; i++) {
|
|
41
|
+
const row = rows[i];
|
|
42
|
+
let isMatch = false;
|
|
43
|
+
|
|
44
|
+
if (searchRegex) {
|
|
45
|
+
// If a valid regex was created, use it for matching
|
|
46
|
+
isMatch = searchRegex.test(row.textContent);
|
|
47
|
+
} else {
|
|
48
|
+
// Otherwise, fall back to the original plain text search
|
|
49
|
+
isMatch = row.textContent
|
|
50
|
+
.toLowerCase()
|
|
51
|
+
.includes(searchValue.toLowerCase());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
row.style.display = isMatch ? '' : 'none';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// loads the search box
|
|
59
|
+
function addSearchBox() {
|
|
60
|
+
var template = document.getElementById('filterTemplate');
|
|
61
|
+
var templateClone = template.content.cloneNode(true);
|
|
62
|
+
templateClone.getElementById('fileSearch').oninput = onFilterInput;
|
|
63
|
+
template.parentElement.appendChild(templateClone);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// loads all columns
|
|
67
|
+
function loadColumns() {
|
|
68
|
+
var colNodes = getTableHeader().querySelectorAll('th'),
|
|
69
|
+
colNode,
|
|
70
|
+
cols = [],
|
|
71
|
+
col,
|
|
72
|
+
i;
|
|
73
|
+
|
|
74
|
+
for (i = 0; i < colNodes.length; i += 1) {
|
|
75
|
+
colNode = colNodes[i];
|
|
76
|
+
col = {
|
|
77
|
+
key: colNode.getAttribute('data-col'),
|
|
78
|
+
sortable: !colNode.getAttribute('data-nosort'),
|
|
79
|
+
type: colNode.getAttribute('data-type') || 'string'
|
|
80
|
+
};
|
|
81
|
+
cols.push(col);
|
|
82
|
+
if (col.sortable) {
|
|
83
|
+
col.defaultDescSort = col.type === 'number';
|
|
84
|
+
colNode.innerHTML =
|
|
85
|
+
colNode.innerHTML + '<span class="sorter"></span>';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return cols;
|
|
89
|
+
}
|
|
90
|
+
// attaches a data attribute to every tr element with an object
|
|
91
|
+
// of data values keyed by column name
|
|
92
|
+
function loadRowData(tableRow) {
|
|
93
|
+
var tableCols = tableRow.querySelectorAll('td'),
|
|
94
|
+
colNode,
|
|
95
|
+
col,
|
|
96
|
+
data = {},
|
|
97
|
+
i,
|
|
98
|
+
val;
|
|
99
|
+
for (i = 0; i < tableCols.length; i += 1) {
|
|
100
|
+
colNode = tableCols[i];
|
|
101
|
+
col = cols[i];
|
|
102
|
+
val = colNode.getAttribute('data-value');
|
|
103
|
+
if (col.type === 'number') {
|
|
104
|
+
val = Number(val);
|
|
105
|
+
}
|
|
106
|
+
data[col.key] = val;
|
|
107
|
+
}
|
|
108
|
+
return data;
|
|
109
|
+
}
|
|
110
|
+
// loads all row data
|
|
111
|
+
function loadData() {
|
|
112
|
+
var rows = getTableBody().querySelectorAll('tr'),
|
|
113
|
+
i;
|
|
114
|
+
|
|
115
|
+
for (i = 0; i < rows.length; i += 1) {
|
|
116
|
+
rows[i].data = loadRowData(rows[i]);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// sorts the table using the data for the ith column
|
|
120
|
+
function sortByIndex(index, desc) {
|
|
121
|
+
var key = cols[index].key,
|
|
122
|
+
sorter = function(a, b) {
|
|
123
|
+
a = a.data[key];
|
|
124
|
+
b = b.data[key];
|
|
125
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
126
|
+
},
|
|
127
|
+
finalSorter = sorter,
|
|
128
|
+
tableBody = document.querySelector('.coverage-summary tbody'),
|
|
129
|
+
rowNodes = tableBody.querySelectorAll('tr'),
|
|
130
|
+
rows = [],
|
|
131
|
+
i;
|
|
132
|
+
|
|
133
|
+
if (desc) {
|
|
134
|
+
finalSorter = function(a, b) {
|
|
135
|
+
return -1 * sorter(a, b);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
for (i = 0; i < rowNodes.length; i += 1) {
|
|
140
|
+
rows.push(rowNodes[i]);
|
|
141
|
+
tableBody.removeChild(rowNodes[i]);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
rows.sort(finalSorter);
|
|
145
|
+
|
|
146
|
+
for (i = 0; i < rows.length; i += 1) {
|
|
147
|
+
tableBody.appendChild(rows[i]);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// removes sort indicators for current column being sorted
|
|
151
|
+
function removeSortIndicators() {
|
|
152
|
+
var col = getNthColumn(currentSort.index),
|
|
153
|
+
cls = col.className;
|
|
154
|
+
|
|
155
|
+
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
|
156
|
+
col.className = cls;
|
|
157
|
+
}
|
|
158
|
+
// adds sort indicators for current column being sorted
|
|
159
|
+
function addSortIndicators() {
|
|
160
|
+
getNthColumn(currentSort.index).className += currentSort.desc
|
|
161
|
+
? ' sorted-desc'
|
|
162
|
+
: ' sorted';
|
|
163
|
+
}
|
|
164
|
+
// adds event listeners for all sorter widgets
|
|
165
|
+
function enableUI() {
|
|
166
|
+
var i,
|
|
167
|
+
el,
|
|
168
|
+
ithSorter = function ithSorter(i) {
|
|
169
|
+
var col = cols[i];
|
|
170
|
+
|
|
171
|
+
return function() {
|
|
172
|
+
var desc = col.defaultDescSort;
|
|
173
|
+
|
|
174
|
+
if (currentSort.index === i) {
|
|
175
|
+
desc = !currentSort.desc;
|
|
176
|
+
}
|
|
177
|
+
sortByIndex(i, desc);
|
|
178
|
+
removeSortIndicators();
|
|
179
|
+
currentSort.index = i;
|
|
180
|
+
currentSort.desc = desc;
|
|
181
|
+
addSortIndicators();
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
for (i = 0; i < cols.length; i += 1) {
|
|
185
|
+
if (cols[i].sortable) {
|
|
186
|
+
// add the click event handler on the th so users
|
|
187
|
+
// dont have to click on those tiny arrows
|
|
188
|
+
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
|
189
|
+
if (el.addEventListener) {
|
|
190
|
+
el.addEventListener('click', ithSorter(i));
|
|
191
|
+
} else {
|
|
192
|
+
el.attachEvent('onclick', ithSorter(i));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// adds sorting functionality to the UI
|
|
198
|
+
return function() {
|
|
199
|
+
if (!getTable()) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
cols = loadColumns();
|
|
203
|
+
loadData();
|
|
204
|
+
addSearchBox();
|
|
205
|
+
addSortIndicators();
|
|
206
|
+
enableUI();
|
|
207
|
+
};
|
|
208
|
+
})();
|
|
209
|
+
|
|
210
|
+
window.addEventListener('load', addSorting);
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAsBA,OAAO,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
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]="
|
|
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]="48b4164f-2397-50ef-9167-465c5ba7b38e")}catch(e){}}();
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import { createServer } from 'http';
|
|
5
5
|
import { Server } from 'socket.io';
|
|
6
6
|
import cors from 'cors';
|
|
7
|
-
import dotenv from 'dotenv';
|
|
8
7
|
import { createExpressMiddleware } from '@trpc/server/adapters/express';
|
|
9
8
|
import { appRouter } from './routers/_app.js';
|
|
10
9
|
import { createTRPCContext, createCallerFactory } from './trpc.js';
|
|
@@ -12,49 +11,43 @@ import { logger } from './utils/logger.js';
|
|
|
12
11
|
import { setupSocketHandlers } from './socket/handlers.js';
|
|
13
12
|
import { bucket } from './lib/googleCloudStorage.js';
|
|
14
13
|
import { prisma } from './lib/prisma.js';
|
|
14
|
+
import { authLimiter, generalLimiter, helmetConfig, uploadLimiter } from './middleware/security.js';
|
|
15
15
|
import * as Sentry from "@sentry/node";
|
|
16
|
+
import { env } from './lib/config/env.js';
|
|
17
|
+
import compression from 'compression';
|
|
18
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
16
19
|
import "./instrument.js";
|
|
17
|
-
dotenv.config();
|
|
18
20
|
const app = express();
|
|
21
|
+
app.use(helmetConfig);
|
|
22
|
+
app.use(compression());
|
|
23
|
+
app.use((req, res, next) => {
|
|
24
|
+
const requestId = uuidv4();
|
|
25
|
+
res.setHeader('X-Request-ID', requestId);
|
|
26
|
+
next();
|
|
27
|
+
});
|
|
28
|
+
app.use(generalLimiter);
|
|
29
|
+
const allowedOrigins = env.NODE_ENV === 'production'
|
|
30
|
+
? [
|
|
31
|
+
'https://www.studious.sh',
|
|
32
|
+
'https://studious.sh',
|
|
33
|
+
env.NEXT_PUBLIC_APP_URL,
|
|
34
|
+
'http://localhost:3000',
|
|
35
|
+
].filter(Boolean)
|
|
36
|
+
: [
|
|
37
|
+
'http://localhost:3000',
|
|
38
|
+
'http://localhost:3001',
|
|
39
|
+
'http://127.0.0.1:3000',
|
|
40
|
+
'http://127.0.0.1:3001',
|
|
41
|
+
env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
42
|
+
];
|
|
19
43
|
// CORS middleware
|
|
20
44
|
app.use(cors({
|
|
21
|
-
origin:
|
|
22
|
-
'http://localhost:3000', // Frontend development server
|
|
23
|
-
'http://localhost:3001', // Server port
|
|
24
|
-
'http://127.0.0.1:3000', // Alternative localhost
|
|
25
|
-
'http://127.0.0.1:3001', // Alternative localhost
|
|
26
|
-
'https://www.studious.sh', // Production frontend
|
|
27
|
-
'https://studious.sh', // Production frontend (without www)
|
|
28
|
-
process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
29
|
-
],
|
|
45
|
+
origin: allowedOrigins,
|
|
30
46
|
credentials: true,
|
|
31
47
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
|
32
48
|
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'x-user'],
|
|
33
49
|
optionsSuccessStatus: 200
|
|
34
50
|
}));
|
|
35
|
-
// Handle preflight OPTIONS requests
|
|
36
|
-
app.options('*', (req, res) => {
|
|
37
|
-
const allowedOrigins = [
|
|
38
|
-
'http://localhost:3000',
|
|
39
|
-
'http://localhost:3001',
|
|
40
|
-
'http://127.0.0.1:3000',
|
|
41
|
-
'http://127.0.0.1:3001',
|
|
42
|
-
'https://www.studious.sh', // Production frontend
|
|
43
|
-
'https://studious.sh', // Production frontend (without www)
|
|
44
|
-
process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
45
|
-
];
|
|
46
|
-
const origin = req.headers.origin;
|
|
47
|
-
if (origin && allowedOrigins.includes(origin)) {
|
|
48
|
-
res.header('Access-Control-Allow-Origin', origin);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
res.header('Access-Control-Allow-Origin', 'http://localhost:3000');
|
|
52
|
-
}
|
|
53
|
-
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
54
|
-
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With, x-user');
|
|
55
|
-
res.header('Access-Control-Allow-Credentials', 'true');
|
|
56
|
-
res.sendStatus(200);
|
|
57
|
-
});
|
|
58
51
|
// CORS debugging middleware
|
|
59
52
|
app.use((req, res, next) => {
|
|
60
53
|
if (req.method === 'OPTIONS' || req.path.includes('trpc')) {
|
|
@@ -82,7 +75,7 @@ app.use((req, res, next) => {
|
|
|
82
75
|
next();
|
|
83
76
|
});
|
|
84
77
|
app.use("/panel", async (_, res) => {
|
|
85
|
-
if (
|
|
78
|
+
if (env.NODE_ENV !== "development") {
|
|
86
79
|
return res.status(404).send("Not Found");
|
|
87
80
|
}
|
|
88
81
|
// Dynamically import renderTrpcPanel only in development
|
|
@@ -97,11 +90,24 @@ app.use("/panel", async (_, res) => {
|
|
|
97
90
|
});
|
|
98
91
|
// Create HTTP server
|
|
99
92
|
const httpServer = createServer(app);
|
|
100
|
-
app.get('/health', (req, res) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
93
|
+
app.get('/health', async (req, res) => {
|
|
94
|
+
try {
|
|
95
|
+
// Check database connectivity
|
|
96
|
+
await prisma.$queryRaw `SELECT 1`;
|
|
97
|
+
res.status(200).json({
|
|
98
|
+
status: 'OK',
|
|
99
|
+
timestamp: new Date().toISOString(),
|
|
100
|
+
uptime: process.uptime(),
|
|
101
|
+
database: 'connected'
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
res.status(503).json({
|
|
106
|
+
status: 'ERROR',
|
|
107
|
+
database: 'disconnected',
|
|
108
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
105
111
|
});
|
|
106
112
|
// Setup Socket.IO
|
|
107
113
|
const io = new Server(httpServer, {
|
|
@@ -113,7 +119,7 @@ const io = new Server(httpServer, {
|
|
|
113
119
|
'http://127.0.0.1:3001', // Alternative localhost
|
|
114
120
|
'https://www.studious.sh', // Production frontend
|
|
115
121
|
'https://studious.sh', // Production frontend (without www)
|
|
116
|
-
|
|
122
|
+
env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
117
123
|
],
|
|
118
124
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
|
119
125
|
credentials: true,
|
|
@@ -313,11 +319,13 @@ app.get('/api/files/:fileId', async (req, res) => {
|
|
|
313
319
|
res.status(500).json({ error: 'Internal server error' });
|
|
314
320
|
}
|
|
315
321
|
});
|
|
322
|
+
app.use('/trpc/auth.login', authLimiter);
|
|
323
|
+
app.use('/trpc/auth.register', authLimiter);
|
|
316
324
|
// File upload endpoint for secure file uploads (supports both POST and PUT)
|
|
317
|
-
app.post('/api/upload/:filePath', async (req, res) => {
|
|
325
|
+
app.post('/api/upload/:filePath', uploadLimiter, async (req, res) => {
|
|
318
326
|
handleFileUpload(req, res);
|
|
319
327
|
});
|
|
320
|
-
app.put('/api/upload/:filePath', async (req, res) => {
|
|
328
|
+
app.put('/api/upload/:filePath', uploadLimiter, async (req, res) => {
|
|
321
329
|
handleFileUpload(req, res);
|
|
322
330
|
});
|
|
323
331
|
function handleFileUpload(req, res) {
|
|
@@ -332,7 +340,7 @@ function handleFileUpload(req, res) {
|
|
|
332
340
|
'http://127.0.0.1:3001',
|
|
333
341
|
'https://www.studious.sh', // Production frontend
|
|
334
342
|
'https://studious.sh', // Production frontend (without www)
|
|
335
|
-
|
|
343
|
+
env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
336
344
|
];
|
|
337
345
|
if (origin && allowedOrigins.includes(origin)) {
|
|
338
346
|
res.header('Access-Control-Allow-Origin', origin);
|
|
@@ -391,7 +399,7 @@ Sentry.setupExpressErrorHandler(app);
|
|
|
391
399
|
// res.statusCode = 500;
|
|
392
400
|
// res.end(res.sentry + "\n");
|
|
393
401
|
// });
|
|
394
|
-
const PORT =
|
|
402
|
+
const PORT = env.PORT || 3001;
|
|
395
403
|
httpServer.listen(PORT, () => {
|
|
396
404
|
logger.info(`Server running on port ${PORT}`, {
|
|
397
405
|
port: PORT,
|
|
@@ -400,10 +408,10 @@ httpServer.listen(PORT, () => {
|
|
|
400
408
|
});
|
|
401
409
|
// log all env variables
|
|
402
410
|
logger.info('Configurations', {
|
|
403
|
-
NODE_ENV:
|
|
404
|
-
PORT:
|
|
405
|
-
NEXT_PUBLIC_APP_URL:
|
|
406
|
-
LOG_MODE:
|
|
411
|
+
NODE_ENV: env.NODE_ENV,
|
|
412
|
+
PORT: env.PORT,
|
|
413
|
+
NEXT_PUBLIC_APP_URL: env.NEXT_PUBLIC_APP_URL,
|
|
414
|
+
LOG_MODE: env.LOG_MODE,
|
|
407
415
|
});
|
|
408
416
|
// Log CORS configuration
|
|
409
417
|
logger.info('CORS Configuration', {
|
|
@@ -412,8 +420,31 @@ logger.info('CORS Configuration', {
|
|
|
412
420
|
'http://localhost:3001',
|
|
413
421
|
'http://127.0.0.1:3000',
|
|
414
422
|
'http://127.0.0.1:3001',
|
|
415
|
-
|
|
423
|
+
env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
416
424
|
]
|
|
417
425
|
});
|
|
426
|
+
const gracefulShutdown = (signal) => {
|
|
427
|
+
logger.info(`Received ${signal}, shutting down gracefully`);
|
|
428
|
+
httpServer.close(() => {
|
|
429
|
+
logger.info('HTTP server closed');
|
|
430
|
+
io.close(() => {
|
|
431
|
+
logger.info('Socket.IO server closed');
|
|
432
|
+
prisma.$disconnect().then(() => {
|
|
433
|
+
logger.info('Database connections closed');
|
|
434
|
+
process.exit(0);
|
|
435
|
+
}).catch((err) => {
|
|
436
|
+
logger.error('Error disconnecting from database', { error: err });
|
|
437
|
+
process.exit(1);
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
// Force shutdown after 10 seconds
|
|
442
|
+
setTimeout(() => {
|
|
443
|
+
logger.error('Forced shutdown after timeout');
|
|
444
|
+
process.exit(1);
|
|
445
|
+
}, 10000);
|
|
446
|
+
};
|
|
447
|
+
process.on('SIGTERM', () => gracefulShutdown('SIGTERM'));
|
|
448
|
+
process.on('SIGINT', () => gracefulShutdown('SIGINT'));
|
|
418
449
|
//# sourceMappingURL=index.js.map
|
|
419
|
-
//# debugId=
|
|
450
|
+
//# debugId=48b4164f-2397-50ef-9167-465c5ba7b38e
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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 * as Sentry from \"@sentry/node\";\n\nimport { renderTrpcPanel } from \"trpc-panel\";\n\nimport \"./instrument.js\";\n\ndotenv.config();\n\nconst app = express();\n\n// CORS middleware\napp.use(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 process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'\n ],\n credentials: true,\n methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],\n allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'x-user'],\n optionsSuccessStatus: 200\n}));\n\n// Handle preflight OPTIONS requests\napp.options('*', (req, res) => {\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 process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'\n ];\n \n const origin = req.headers.origin;\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-Methods', 'GET, POST, PUT, DELETE, OPTIONS');\n res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With, x-user');\n res.header('Access-Control-Allow-Credentials', 'true');\n res.sendStatus(200);\n});\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\napp.use(\"/panel\", async (_, res) => {\n if (process.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', (req, res) => {\n res.status(200).json({ message: 'OK' });\n});\n\napp.get('/test-sentry', (req, res) => {\n throw new Error('Test error');\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 process.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\n// File upload endpoint for secure file uploads (supports both POST and PUT)\napp.post('/api/upload/:filePath', async (req, res) => {\n handleFileUpload(req, res);\n});\n\napp.put('/api/upload/:filePath', 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 process.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 = process.env.PORT || 3001;\n\nhttpServer.listen(PORT, () => {\n logger.info(`Server running on port ${PORT}`, { \n port: PORT,\n services: ['tRPC', 'Socket.IO']\n });\n}); \n\n// log all env variables\nlogger.info('Configurations', {\n NODE_ENV: process.env.NODE_ENV,\n PORT: process.env.PORT,\n NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,\n LOG_MODE: process.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 process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'\n ]\n});"],"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;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,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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AAmC,EAAE,EAAE;QACrE,OAAO,iBAAiB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CACH,CAAC;AAEF,sFAAsF;AACtF,sCAAsC;AACtC,MAAM,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;AAErC,kDAAkD;AAClD,+DAA+D;AAC/D,yDAAyD;AACzD,0BAA0B;AAC1B,gCAAgC;AAChC,MAAM;AAGN,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;AAEtC,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;IAC3B,MAAM,CAAC,IAAI,CAAC,0BAA0B,IAAI,EAAE,EAAE;QAC5C,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;KAChC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,wBAAwB;AACxB,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;IAC5B,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;IAC9B,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;IACtB,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;IACpD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;CAC/B,CAAC,CAAC;AAEH,yBAAyB;AACzB,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE;IAChC,cAAc,EAAE;QACd,uBAAuB;QACvB,uBAAuB;QACvB,uBAAuB;QACvB,uBAAuB;QACvB,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,uBAAuB;KAC3D;CACF,CAAC,CAAC","debug_id":"98b1ae42-791e-5668-a2f9-5b3781e34928"}
|
|
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';\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());\n\napp.use((req, res, next) => {\n const requestId = uuidv4();\n res.setHeader('X-Request-ID', requestId);\n next();\n});\n\napp.use(generalLimiter);\n\nconst allowedOrigins = env.NODE_ENV === 'production'\n? [\n 'https://www.studious.sh',\n 'https://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 optionsSuccessStatus: 200\n}));\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\napp.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// 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\nhttpServer.listen(PORT, () => {\n logger.info(`Server running on port ${PORT}`, { \n port: PORT,\n services: ['tRPC', 'Socket.IO']\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 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 // 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,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,CAAC,QAAQ,CAAC,CAAC,CAAC","debug_id":"48b4164f-2397-50ef-9167-465c5ba7b38e"}
|
package/dist/instrument.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
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]="
|
|
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
3
|
import * as Sentry from "@sentry/node";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
}
|
|
10
17
|
//# sourceMappingURL=instrument.js.map
|
|
11
|
-
//# debugId=
|
|
18
|
+
//# debugId=eedba78e-175f-5c0b-809f-3af467929bd2
|
package/dist/instrument.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument.js","sources":["instrument.ts"],"sourceRoot":"/","sourcesContent":["import * as Sentry from \"@sentry/node\";\n\
|
|
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"}
|