mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-16 06:11:38 +00:00
Feature: use nuxt bridge to bundle client
This commit is contained in:
parent
98c117f0b8
commit
228b5203a8
23 changed files with 8484 additions and 19783 deletions
|
|
@ -139,7 +139,7 @@ class Server {
|
|||
Logger.info('=== Starting Server ===')
|
||||
await this.init()
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
this.clientRouter.start()
|
||||
await this.clientRouter.start()
|
||||
}
|
||||
|
||||
const app = express()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const express = require('express')
|
||||
const mime = require('mime-types')
|
||||
const Path = require('path')
|
||||
const Logger = require('../Logger')
|
||||
|
||||
|
|
@ -14,18 +15,15 @@ class ClientRouter {
|
|||
|
||||
async init () {
|
||||
const clientDir = Path.join(this.appRoot, '/client')
|
||||
const { loadNuxt } = require(Path.resolve(clientDir, 'node_modules/nuxt'))
|
||||
this.client = await loadNuxt({ rootDir: clientDir, for: 'start' })
|
||||
const { handler } = await import(Path.join(clientDir, '.output/server/index.mjs'))
|
||||
this.client = handler
|
||||
}
|
||||
|
||||
async start () {
|
||||
Logger.info('[Client] Starting')
|
||||
await this.init()
|
||||
|
||||
this.router.use(this.client.render)
|
||||
|
||||
this.client.hook('error', (err) => Logger.error('[Client]', err))
|
||||
this.client.ready().then(() => Logger.info('[Client] Ready'))
|
||||
this.router.use('/', this.client)
|
||||
}
|
||||
|
||||
async stop () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue