Skip to content

Commit b02751e

Browse files
committed
sha
1 parent 0ee506a commit b02751e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,20 @@ app.get('/add-sha/:sha', (req, res) => {
112112
})
113113

114114
app.get('/collect-sha/:sha', async (req, res) => {
115-
try {
116115
const ip = req.headers['x-forwarded-for']
117116
const metadata = JSON.parse(Base64.decode(req.headers['metadata']))
118117
const {headers, isp, memory, platform, hardwareConcurrency, graphics} = metadata
119-
const item = await Item.findOne({where: { sha: req.params.sha }})
120-
if (item !== null) {
118+
const item = await Item.findAll({where: { sha: req.params.sha }})
119+
if (item.length > 0) {
121120
return res.json({message: "visited"})
122121
} else {
123122
console.log(JSON.stringify(item, null, 2))
124123
const newItem = await Item.create({
125124
sha: req.params.sha,
126125
ip, headers, isp, platform, memory, hardwareConcurrency, graphics
127-
})
126+
}).catch(e => {console.log(e)})
128127
return res.json({item: newItem})
129128
}
130-
} catch {
131-
return res.status(422).json({message: "Something Went Wrong"})
132-
}
133129
})
134130

135131
app.get('/scan', async (req, res) => {

0 commit comments

Comments
 (0)