Last active
January 20, 2020 21:39
-
-
Save chadfurman/837aeb25e882d3c3cdefeab31552b138 to your computer and use it in GitHub Desktop.
A server for pingme's online status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from 'express' | |
const app = express() | |
let myTimer = null | |
let online = false | |
const timeout = 30 * 60 * 1000 // number of milliseconds in 30 minutes | |
app.post('/pingme', (req,res) => { | |
online = true | |
clearTimeout(myTimer) | |
myTimer = setTimeout(() => { | |
offline = false | |
}, timeout) | |
res.send() | |
}) | |
app.post('/online', (req,res) => { | |
res.json({online} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment