First commit, phased 1 and 2 created but untested

This commit is contained in:
bepis
2026-10-20 07:40:35 +11:00
commit 7a3e408ffc
66 changed files with 5639 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const http = require('node:http');
const { createApp } = require('../src/app');
function startServer(app) {
return new Promise((resolve) => {
const server = app.listen(0, () => {
const port = server.address().port;
resolve({ server, port });
});
});
}
test('GET /api/health returns { ok: true }', async () => {
const app = createApp();
const { server, port } = await startServer(app);
try {
const result = await new Promise((resolve, reject) => {
http.get(`http://localhost:${port}/api/health`, (res) => {
let data = '';
res.on('data', (chunk) => { data += chunk; });
res.on('end', () => {
resolve({ status: res.statusCode, body: JSON.parse(data) });
});
res.on('error', reject);
});
});
assert.equal(result.status, 200);
assert.equal(result.body.ok, true);
} finally {
server.close();
}
});