chore: server code formatting

This commit is contained in:
Rafael Taranto 2025-05-12 15:35:00 +01:00
parent aedabcbdee
commit 68517170e2
234 changed files with 9824 additions and 6195 deletions

View file

@ -1,6 +1,6 @@
const crypto = require('crypto')
function sha256 (buf) {
function sha256(buf) {
if (!buf) return null
const hash = crypto.createHash('sha256')
@ -9,10 +9,13 @@ function sha256 (buf) {
}
const populateDeviceId = function (req, res, next) {
const peerCert = req.socket.getPeerCertificate ? req.socket.getPeerCertificate() : null
const peerCert = req.socket.getPeerCertificate
? req.socket.getPeerCertificate()
: null
const deviceId = peerCert?.raw ? sha256(peerCert.raw) : null
if (!deviceId) return res.status(500).json({ error: 'Unable to find certificate' })
if (!deviceId)
return res.status(500).json({ error: 'Unable to find certificate' })
req.deviceId = deviceId
req.deviceTime = req.get('date')