UCP Version

node v14.20.1
version: 3.0.5
endpointsharetweet
const result = await require('got')('https://community.fandom.com/wikia.php?controller=MercuryApi&method=getWikiVariables').json(); const version = result.data.wgPerformanceMonitoringSoftwareVersion.split('@')[0].replace('release-', ''); const cookie = require('cookie'); exports.endpoint = (req, res) => { res.setHeader('Content-Type', 'text/plain'); if (req.url === '/change') { const cookies = cookie.parse(req.headers.cookie || ''); if (cookies.version) { if (version > cookies.version) { res.setHeader('Set-Cookie', cookie.serialize('version', String(version), { httpOnly: true, sameSite: 'strict', secure: true, maxAge: 60 * 60 * 24 * 7 })); res.end('UCP has updated!'); } else { res.end('No new version since last check.'); } } else { res.setHeader('Set-Cookie', cookie.serialize('version', String(version), { httpOnly: true, sameSite: 'strict', secure: true, maxAge: 60 * 60 * 24 * 7 })); res.end('No cookie was found, setting cookie.'); } } else { res.end(version); } }
Loading…

no comments

    sign in to comment