forked from SekibOmazic/deploy-on-fargate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (31 loc) · 844 Bytes
/
index.js
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
import express from 'express'
const app = express()
const PORT = 80
app.use(express.json())
const BLUE = 'cornflowerblue'
const GREEN = 'green'
const RED = 'red'
// start with the blue background
const color = BLUE
const page = `
<head>
<title>Blue-Green deployment</title>
</head>
<body style="display: flex; align-items: center; justify-content: center; background-color: ${color};">
<h1 style="color: white;">
Hello from AWS Fargate
</h1>
</body>
`
app.get('/', (_req, res) => {
res.setHeader('Content-type', 'text/html')
return res.send(page)
})
app.use('/color', (_req, res) => res.json({
color: color
}))
app.get('/health', (_req, res) => res.send('Healthy!'))
app.all('*', (_req, res) => res.send('Ooops, no such route'))
app.listen(PORT, () =>
console.log(`Server running on port: http://localhost:${PORT}`)
)