-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (63 loc) · 1.9 KB
/
index.js
File metadata and controls
69 lines (63 loc) · 1.9 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
const express = require('express');
const app = express();
const deploymentVersion = process.env.CYCLE_DEPLOYMENT_VERSION;
// Define a function to handle all specified routes
const commonHandler = (req, res) => {
const htmlContent = `
<html>
<head>
<title>Deployments Data</title>
<style>
body {
background-color: #282c34;
color: white; /* White text */
height: 100vh; /* Full height */
margin: 0;
display: flex;
justify-content: center; /* Center horizontally */
align-items: center; /* Center vertically */
font-family: Arial, sans-serif;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
pre {
font-size: 32px;
line-height: 1.5;
overflow: auto; /* Enables scrolling if content is too wide */
}
p {
font-size: 1.17em;
}
</style>
</head>
<body>
<img src="https://static.cycle.io/icons/logo/logo-white.svg" className="App-logo" alt="logo" width="400px" />
<p><b>Deployment Version</b>: ${deploymentVersion}<p>
</body>
</html>
`;
res.send(htmlContent);
};
// Define routes
app.get('/_health', (req, res) => {
res.status(200).json({ message: 'OK' });
});
app.get('/', commonHandler);
app.get('/apple', commonHandler);
app.get('/orange', commonHandler);
app.get('/banana', commonHandler);
const server = app.listen(3000, () => {
console.log('Server is running on port 3000');
});
process.on('SIGINT', () => {
console.log('Received SIGINT, shutting down server...');
server.close(() => {
console.log('Server has been shut down.');
process.exit(0);
});
});