-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
96 lines (89 loc) · 2.62 KB
/
Copy pathserver.js
File metadata and controls
96 lines (89 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const express = require('express');
const app = express();
const port = process.env.PORT || 80;
app.get('/', (req, res) => {
const html = `
<!DOCTYPE html>
<html>
<head>
<title>Balena Hello World with SBOM</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
min-height: 100vh;
}
.container {
background: rgba(255, 255, 255, 0.1);
border-radius: 10px;
padding: 30px;
margin-top: 50px;
}
h1 {
text-align: center;
font-size: 2.5em;
margin-bottom: 20px;
}
.info {
background: rgba(0, 0, 0, 0.2);
border-radius: 5px;
padding: 20px;
margin: 20px 0;
}
.feature {
margin: 10px 0;
padding-left: 20px;
}
.timestamp {
text-align: center;
margin-top: 30px;
opacity: 0.8;
}
</style>
</head>
<body>
<div class="container">
<h1>🚀 Hello from Balena!</h1>
<div class="info">
<h2>About This Application</h2>
<p>This is a demonstration application showing how to:</p>
<div class="feature">✅ Deploy Node.js apps to Balena devices</div>
<div class="feature">✅ Use GitHub Actions for CI/CD</div>
<div class="feature">✅ Generate Software Bill of Materials (SBOM)</div>
<div class="feature">✅ Upload SBOM as release assets to Balena</div>
</div>
<div class="info">
<h2>Environment Information</h2>
<div class="feature">Node Version: ${process.version}</div>
<div class="feature">Port: ${port}</div>
<div class="feature">Platform: ${process.platform}</div>
<div class="feature">Architecture: ${process.arch}</div>
</div>
<div class="timestamp">
Current Time: ${new Date().toLocaleString()}
</div>
</div>
</body>
</html>
`;
res.send(html);
});
app.get('/health', (req, res) => {
res.json({
status: 'healthy',
timestamp: new Date().toISOString(),
uptime: process.uptime()
});
});
app.listen(port, () => {
console.log(`Hello World app listening on port ${port}`);
console.log(`Visit http://localhost:${port} to see the application`);
});
process.on('SIGTERM', () => {
console.log('SIGTERM signal received: closing HTTP server');
process.exit(0);
});