-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
31 lines (23 loc) · 906 Bytes
/
app.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
import { displayText, reset } from './displayFunctions.js'
import { main } from './sets.js'
import Express from 'express'
import dotenv from 'dotenv'
dotenv.config()
const PORT = process.env.PORT
const HOSTNAME = process.env.HOSTNAME
const app = Express()
app.listen(PORT, HOSTNAME, () => {
console.log(`Server running at http://${HOSTNAME}:${PORT}/`)
})
// routes
app.get('/launch/set/main', (req, res) =>
main().then(result => res.send(result)).catch(err => res.send(err)))
app.get('/launch/text/:text/:r/:g/:b/:speed', (req, res) =>
displayText(req.params.text, req.params.speed || 2, req.params.r || 255, req.params.g || 255, req.params.b || 255)
.then(result => res.send(result)).catch(err => res.send(err)))
app.get('/reset', (req, res) => res.send(reset()))
app.get('/', (req, res) => res.send({
routes: [
'/launch/set/main', '/reset', '/launch/text/:text/:r/:g/:b/:speed'
]
}))