summaryrefslogtreecommitdiff
path: root/server.mjs
diff options
context:
space:
mode:
authorLi Zhineng <[email protected]>2025-07-01 11:33:02 +0800
committerLi Zhineng <[email protected]>2025-07-01 11:33:02 +0800
commit9ece6a3b2ded2689e8de1719d4f7a4ef39bc6942 (patch)
treef7cfdc629339a07fde4f9e441d6a48fc4f680eb5 /server.mjs
parent0800e4a15238bb0f09d9befacc3ea01b0ae374f8 (diff)
downloadserver-9ece6a3b2ded2689e8de1719d4f7a4ef39bc6942.tar.gz
server-9ece6a3b2ded2689e8de1719d4f7a4ef39bc6942.zip
add tests
Diffstat (limited to 'server.mjs')
-rw-r--r--server.mjs20
1 files changed, 10 insertions, 10 deletions
diff --git a/server.mjs b/server.mjs
index e9300d7..6baa679 100644
--- a/server.mjs
+++ b/server.mjs
@@ -1,18 +1,18 @@
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)
- }))
+ if (req.method === 'GET' && req.url === '/') {
+ res.writeHead(200, { 'Content-Type': 'text/plain' })
+ res.end('It works!\n')
+ } else if (req.method === 'GET' && req.url === '/gettime') {
+ res.writeHead(200, { 'Content-Type': 'application/json' })
+ 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 }
- }))
+ res.writeHead(200, { 'Content-Type': 'application/json' })
+ res.end(JSON.stringify({ status: 200, data: { eagleId: 0 } }))
} else {
- res.end('It works!\n')
+ res.writeHead(404)
+ res.end()
}
})