v1: hello world node app

This commit is contained in:
Dev
2026-11-04 12:28:44 +08:00
commit 7b10346296
4 changed files with 57 additions and 0 deletions

30
index.js Normal file
View File

@@ -0,0 +1,30 @@
const http = require('http');
const os = require('os');
const PORT = Number(process.env.PORT || 3000);
const VERSION = process.env.APP_VERSION || 'v1';
const startedAt = new Date().toISOString();
const server = http.createServer((req, res) => {
if (req.url === '/healthz') {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('ok');
return;
}
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
res.end(JSON.stringify({
message: 'Hello World from Gitea + Coolify!',
version: VERSION,
hostname: os.hostname(),
startedAt,
now: new Date().toISOString(),
path: req.url
}, null, 2));
});
server.listen(PORT, '0.0.0.0', () => {
console.log(`hello-coolify ${VERSION} listening on 0.0.0.0:${PORT}`);
});
process.on('SIGTERM', () => server.close(() => process.exit(0)));