mirror of
https://github.com/Eugeny/tabby-web.git
synced 2026-08-17 23:06:04 +01:00
.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { install } from 'source-map-support'
|
||||
import * as throng from 'throng'
|
||||
|
||||
import 'zone.js/dist/zone-node'
|
||||
import './ssr-polyfills'
|
||||
@@ -9,31 +10,43 @@ import { ngExpressEngine } from '@nguniversal/express-engine'
|
||||
import * as express from 'express'
|
||||
import { join } from 'path'
|
||||
|
||||
|
||||
install()
|
||||
enableProdMode()
|
||||
|
||||
const app = express()
|
||||
|
||||
const PORT = process.env.PORT || 4000
|
||||
const DIST_FOLDER = join(process.cwd(), 'build')
|
||||
|
||||
import { AppServerModule } from './app.server.module'
|
||||
|
||||
app.engine('html', ngExpressEngine({
|
||||
const engine = ngExpressEngine({
|
||||
bootstrap: AppServerModule,
|
||||
}))
|
||||
|
||||
app.set('view engine', 'html')
|
||||
app.set('views', DIST_FOLDER)
|
||||
|
||||
app.get('*.*', express.static(DIST_FOLDER, {
|
||||
maxAge: '1y',
|
||||
}))
|
||||
|
||||
app.get('*', (req, res) => {
|
||||
res.render('index', { req })
|
||||
})
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Node Express server listening on http://localhost:${PORT}`)
|
||||
function start () {
|
||||
const app = express()
|
||||
|
||||
const PORT = process.env.PORT || 4000
|
||||
const DIST_FOLDER = join(process.cwd(), 'build')
|
||||
|
||||
app.engine('html', engine)
|
||||
|
||||
app.set('view engine', 'html')
|
||||
app.set('views', DIST_FOLDER)
|
||||
|
||||
app.get('*.*', express.static(DIST_FOLDER, {
|
||||
maxAge: '1y',
|
||||
}))
|
||||
|
||||
app.get('*', (req, res) => {
|
||||
res.render('index', { req })
|
||||
})
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Node Express server listening on http://localhost:${PORT}`)
|
||||
})
|
||||
}
|
||||
|
||||
const WORKERS = process.env.WEB_CONCURRENCY || 4
|
||||
throng({
|
||||
workers: WORKERS,
|
||||
lifetime: Infinity,
|
||||
start,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user