-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
68 lines (57 loc) · 1.79 KB
/
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
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
const express = require('express')
, app = express()
, openurl = require('openurl')
, fs = require('fs-extra')
, path = require('path')
, CFonts = require('cfonts')
, splitSlice = require('split-slice')
const port = process.env.PORT || 3000
const distFiles = fs.readdirSync(
path.join(__dirname, 'dist')
)
app.use('/', async (req, res, next) => {
const urlFilename = path.basename(req.url)
const filename = urlFilename ? urlFilename : 'index.html'
const findFilename = distFiles.find(distFile => distFile === filename)
if (findFilename) {
const filePath = path.join(__dirname, 'dist', findFilename)
res.sendFile(filePath)
} else {
next()
}
})
app.listen(port, () => {
console.clear()
console.log('')
console.log('')
CFonts.say('Radio|Station|Launcher', {
font: 'simple',
align: 'center',
colors: ['yellow'],
background: 'transparent',
letterSpacing: 1,
space: false,
env: 'node',
})
const launcherHost = `http://127.0.0.1:${port}`
CFonts.say(`Open launcher url: ${launcherHost}${' '.repeat(32-launcherHost.length)}`, {
font: 'console',
align: 'center',
colors: ['yellow'],
background: 'transparent',
space: true,
lineHeight: 0,
env: 'node'
})
const message = splitSlice(`It will take some time to start and start playback in the browser... open the page and wait. If you have any questions, please contact telegram: @prohetamine. And don't be afraid to help the project. by Stas Prohetamie 2022.01.27`, 60, { space: true, align: 'left' }).join('|')
CFonts.say(message, {
font: 'console',
align: 'center',
colors: ['yellow'],
background: 'transparent',
space: false,
lineHeight: 0,
env: 'node'
})
openurl.open(launcherHost)
})