mirror of
https://github.com/Eugeny/tabby-web.git
synced 2026-08-18 07:16:03 +01:00
wip
This commit is contained in:
@@ -18,63 +18,68 @@ enableProdMode()
|
||||
import { AppServerModule } from './app.server.module'
|
||||
|
||||
const engine = ngExpressEngine({
|
||||
bootstrap: AppServerModule,
|
||||
bootstrap: AppServerModule,
|
||||
})
|
||||
|
||||
const hardlinks = {
|
||||
'cwd-detection': 'https://github.com/Eugeny/tabby/wiki/Shell-working-directory-reporting',
|
||||
'privacy-policy': 'https://github.com/Eugeny/tabby/wiki/Privacy-Policy-for-Tabby-Web',
|
||||
'terms-of-use': 'https://github.com/Eugeny/tabby/wiki/Terms-of-Use-of-Tabby-Web',
|
||||
'cwd-detection': 'https://github.com/Eugeny/tabby/wiki/Shell-working-directory-reporting',
|
||||
'privacy-policy': 'https://github.com/Eugeny/tabby/wiki/Privacy-Policy-for-Tabby-Web',
|
||||
'terms-of-use': 'https://github.com/Eugeny/tabby/wiki/Terms-of-Use-of-Tabby-Web',
|
||||
}
|
||||
|
||||
function start () {
|
||||
const app = express()
|
||||
const app = express()
|
||||
|
||||
const PORT = process.env.PORT || 8000
|
||||
const DIST_FOLDER = join(process.cwd(), 'build')
|
||||
const PORT = process.env.PORT ?? 8000
|
||||
const DIST_FOLDER = join(process.cwd(), 'build')
|
||||
|
||||
app.engine('html', engine)
|
||||
app.engine('html', engine)
|
||||
|
||||
app.set('view engine', 'html')
|
||||
app.set('views', DIST_FOLDER)
|
||||
app.set('view engine', 'html')
|
||||
app.set('views', DIST_FOLDER)
|
||||
|
||||
app.use('/static', express.static(DIST_FOLDER, {
|
||||
maxAge: '1y',
|
||||
}))
|
||||
app.use('/static', express.static(DIST_FOLDER, {
|
||||
maxAge: '1y',
|
||||
}))
|
||||
|
||||
app.get(['/', '/app', '/login', '/features'], (req, res) => {
|
||||
res.render(
|
||||
'index',
|
||||
{
|
||||
req,
|
||||
providers: [
|
||||
{ provide: 'BACKEND_URL', useValue: process.env.BACKEND_URL ?? '' },
|
||||
],
|
||||
},
|
||||
(err: Error, html: string) => {
|
||||
html = html.replace('{{backendURL}}', process.env.BACKEND_URL ?? '')
|
||||
res.status(err ? 500 : 200).send(html || err.message)
|
||||
},
|
||||
)
|
||||
})
|
||||
app.get(['/', '/app', '/login', '/features'], (req, res) => {
|
||||
res.render(
|
||||
'index',
|
||||
{
|
||||
req,
|
||||
providers: [
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
{ provide: 'BACKEND_URL', useValue: process.env.BACKEND_URL ?? '' },
|
||||
],
|
||||
},
|
||||
(err?: Error, html?: string) => {
|
||||
if (html) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
html = html.replace('{{backendURL}}', process.env.BACKEND_URL ?? '')
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
res.status(err ? 500 : 200).send(html ?? err!.message)
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
app.get(['/terminal'], (req, res) => {
|
||||
res.sendFile(join(DIST_FOLDER, 'terminal.html'))
|
||||
})
|
||||
app.get(['/terminal'], (req, res) => {
|
||||
res.sendFile(join(DIST_FOLDER, 'terminal.html'))
|
||||
})
|
||||
|
||||
for (const [key, value] of Object.entries(hardlinks)) {
|
||||
app.get(`/go/${key}`, (req, res) => res.redirect(value))
|
||||
}
|
||||
for (const [key, value] of Object.entries(hardlinks)) {
|
||||
app.get(`/go/${key}`, (req, res) => res.redirect(value))
|
||||
}
|
||||
|
||||
process.umask(0o002)
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Node Express server listening on http://localhost:${PORT}`)
|
||||
})
|
||||
process.umask(0o002)
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Node Express server listening on http://localhost:${PORT}`)
|
||||
})
|
||||
}
|
||||
|
||||
const WORKERS = process.env.WEB_CONCURRENCY || 4
|
||||
const WORKERS = process.env.WEB_CONCURRENCY ?? 4
|
||||
throng({
|
||||
workers: WORKERS,
|
||||
lifetime: Infinity,
|
||||
start,
|
||||
workers: WORKERS,
|
||||
lifetime: Infinity,
|
||||
start,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user