31 lines
852 B
JavaScript
31 lines
852 B
JavaScript
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 v2 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)));
|