v1: hello world node app
This commit is contained in:
30
index.js
Normal file
30
index.js
Normal 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)));
|
||||
Reference in New Issue
Block a user