summaryrefslogtreecommitdiff
path: root/server.mjs
blob: 43da1f34806c37317cfff6f6cd172352eb7ecdbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { createServer } from 'node:http'

const server = createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' })

  if (req.method === 'GET' && req.url === '/gettime') {
      res.end(JSON.stringify({
        time: Math.floor(Date.now() / 1000)
      }))
  } else if (req.method === 'GET' && req.url.startsWith('/eagle')) {
      res.end(JSON.stringify({
          status: 200, data: { eagleId: 0 }
      }))
  } else {
      res.end('It works!\n')
  }
})

server.listen(80, '0.0.0.0', () => {
  console.log('Listening on 0.0.0.0:80')
})