Skip to content

Instantly share code, notes, and snippets.

@chadfurman
Last active January 20, 2020 21:39
Show Gist options
  • Save chadfurman/837aeb25e882d3c3cdefeab31552b138 to your computer and use it in GitHub Desktop.
Save chadfurman/837aeb25e882d3c3cdefeab31552b138 to your computer and use it in GitHub Desktop.
A server for pingme's online status
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