Skip to content

Commit ddb64df

Browse files
authored
Merge pull request #401 from BobDu/mongo-type
chore: backend not response mongodb UpdateResult data
2 parents ed2fc20 + c82fb94 commit ddb64df

File tree

4 files changed

+107
-82
lines changed

4 files changed

+107
-82
lines changed

service/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"https-proxy-agent": "^5.0.1",
3636
"isomorphic-fetch": "^3.0.0",
3737
"jwt-decode": "^3.1.2",
38-
"mongodb": "^5.1.0",
38+
"mongodb": "^5.9.2",
3939
"node-fetch": "^3.3.0",
4040
"nodemailer": "^6.9.1",
4141
"request-ip": "^3.3.0",
@@ -44,7 +44,6 @@
4444
"devDependencies": {
4545
"@antfu/eslint-config": "^0.35.3",
4646
"@types/express": "^4.17.17",
47-
"@types/mongodb": "^4.0.7",
4847
"@types/node": "^18.14.6",
4948
"eslint": "^8.35.0",
5049
"jsonwebtoken": "^9.0.0",

service/pnpm-lock.yaml

Lines changed: 53 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service/src/index.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ router.post('/room-rename', auth, async (req, res) => {
109109
try {
110110
const userId = req.headers.userId as string
111111
const { title, roomId } = req.body as { title: string; roomId: number }
112-
const room = await renameChatRoom(userId, title, roomId)
113-
res.send({ status: 'Success', message: null, data: room })
112+
const success = await renameChatRoom(userId, title, roomId)
113+
if (success)
114+
res.send({ status: 'Success', message: null, data: null })
115+
else
116+
res.send({ status: 'Fail', message: 'Saved Failed', data: null })
114117
}
115118
catch (error) {
116119
console.error(error)
@@ -171,11 +174,14 @@ router.post('/room-delete', auth, async (req, res) => {
171174
const userId = req.headers.userId as string
172175
const { roomId } = req.body as { roomId: number }
173176
if (!roomId || !await existsChatRoom(userId, roomId)) {
174-
res.send({ status: 'Fail', message: 'Unknow room', data: null })
177+
res.send({ status: 'Fail', message: 'Unknown room', data: null })
175178
return
176179
}
177-
await deleteChatRoom(userId, roomId)
178-
res.send({ status: 'Success', message: null })
180+
const success = await deleteChatRoom(userId, roomId)
181+
if (success)
182+
res.send({ status: 'Success', message: null, data: null })
183+
else
184+
res.send({ status: 'Fail', message: 'Saved Failed', data: null })
179185
}
180186
catch (error) {
181187
console.error(error)
@@ -190,7 +196,6 @@ router.get('/chat-history', auth, async (req, res) => {
190196
const lastId = req.query.lastId as string
191197
if (!roomId || !await existsChatRoom(userId, roomId)) {
192198
res.send({ status: 'Success', message: null, data: [] })
193-
// res.send({ status: 'Fail', message: 'Unknow room', data: null })
194199
return
195200
}
196201
const chats = await getChats(roomId, !isNotEmptyString(lastId) ? null : parseInt(lastId))
@@ -261,7 +266,6 @@ router.get('/chat-response-history', auth, async (req, res) => {
261266
const index = +req.query.index
262267
if (!roomId || !await existsChatRoom(userId, roomId)) {
263268
res.send({ status: 'Success', message: null, data: [] })
264-
// res.send({ status: 'Fail', message: 'Unknow room', data: null })
265269
return
266270
}
267271
const chat = await getChat(roomId, uuid)
@@ -318,7 +322,7 @@ router.post('/chat-delete', auth, async (req, res) => {
318322
const userId = req.headers.userId as string
319323
const { roomId, uuid, inversion } = req.body as { roomId: number; uuid: number; inversion: boolean }
320324
if (!roomId || !await existsChatRoom(userId, roomId)) {
321-
res.send({ status: 'Fail', message: 'Unknow room', data: null })
325+
res.send({ status: 'Fail', message: 'Unknown room', data: null })
322326
return
323327
}
324328
await deleteChat(roomId, uuid, inversion)
@@ -347,7 +351,7 @@ router.post('/chat-clear', auth, async (req, res) => {
347351
const userId = req.headers.userId as string
348352
const { roomId } = req.body as { roomId: number }
349353
if (!roomId || !await existsChatRoom(userId, roomId)) {
350-
res.send({ status: 'Fail', message: 'Unknow room', data: null })
354+
res.send({ status: 'Fail', message: 'Unknown room', data: null })
351355
return
352356
}
353357
await clearChat(roomId)

0 commit comments

Comments
 (0)