Skip to content

Commit accb9ed

Browse files
committed
better head check
1 parent d6e17ce commit accb9ed

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

controllers/history.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ const queryHeadRequest = async function (req, res, next) {
114114
let props = req.body
115115
const { limit, skip } = getPagination(req.query, 100)
116116
try {
117-
let matches = await db.find(props).limit(limit).skip(skip).toArray()
118-
if (matches.length) {
119-
const size = Buffer.byteLength(JSON.stringify(matches))
120-
res.set("Content-Length", size)
117+
const matchCount = await db.countDocuments(props, { limit, skip })
118+
if (matchCount > 0) {
119+
res.set("Content-Length", 0)
121120
res.status(200).end()
122121
return
123122
}

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
},
2626
"scripts": {
2727
"start": "node ./bin/rerum_v1.js",
28-
"test": "jest",
29-
"runtest": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
28+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
3029
},
3130
"dependencies": {
3231
"cookie-parser": "~1.4.7",

0 commit comments

Comments
 (0)