SPA
This commit is contained in:
+22
-17
@@ -22,9 +22,9 @@ import { Injector } from '../Injector/Injector';
|
||||
import { Shoutbox } from '../Components/Shoutbox/Shoutbox';
|
||||
import { PubSub } from '../Components/PubSub/PubSub';
|
||||
|
||||
import { ngExpressEngine } from '@nguniversal/express-engine';
|
||||
import { APP_BASE_HREF } from '@angular/common';
|
||||
import { AppServerModule } from './app.server.module';
|
||||
//import { ngExpressEngine } from '../../frontend/node_modules/@nguniversal/express-engine';
|
||||
//import { APP_BASE_HREF } from '../../frontend/';
|
||||
//import { AppServerModule } from './app.server.module';
|
||||
|
||||
|
||||
const logger = getLogger("admin", 'debug')
|
||||
@@ -134,13 +134,12 @@ implements TableDefinitionExporter, IAdmin {
|
||||
|
||||
let port:number = this.config.getConfig().httpPort
|
||||
this.express = express()
|
||||
this.express.use('/', express.static('static'))
|
||||
|
||||
|
||||
/*
|
||||
this.express.engine('html', ngExpressEngine({
|
||||
bootstrap: AppServerModule,
|
||||
}));
|
||||
|
||||
|
||||
this.express.set('view engine', 'html');
|
||||
this.express.set('views', 'static');
|
||||
|
||||
@@ -148,15 +147,23 @@ implements TableDefinitionExporter, IAdmin {
|
||||
this.express.get('*.*', express.static('static', {
|
||||
maxAge: '1y'
|
||||
}));
|
||||
|
||||
|
||||
this.express.get("/", (request, response) => {
|
||||
response.status(200)
|
||||
response.sendFile('index.html');
|
||||
})
|
||||
|
||||
// All regular routes use the Universal engine
|
||||
this.express.get('*', (req, res) => {
|
||||
res.render('index', { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
|
||||
res.status(301)
|
||||
res.redirect('/')
|
||||
//res.render('index', { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
|
||||
});
|
||||
*/
|
||||
/* */
|
||||
// get the compiled FrontendPlugins.js
|
||||
this.express.use('/', express.static('static'))
|
||||
|
||||
/**
|
||||
* get the compiled FrontendPlugins.js
|
||||
*/
|
||||
this.express.get('/plugins/:id'+".js", async (request, response) => {
|
||||
const pth = Path.resolve("plugins/"+request.params.id, "FrontendPlugin.js");
|
||||
const file = await fs.readFile(pth)
|
||||
@@ -167,17 +174,13 @@ implements TableDefinitionExporter, IAdmin {
|
||||
response.send(frontend)
|
||||
})
|
||||
|
||||
/**
|
||||
* serve the index.html from the static folder
|
||||
*/
|
||||
// serve the index.html from the static folder
|
||||
this.express.get("/", (request, response) => {
|
||||
response.status(200)
|
||||
response.sendFile('index.html');
|
||||
})
|
||||
|
||||
/**
|
||||
* redirect all the other traffic to the single page app
|
||||
*/
|
||||
// redirect all the other traffic to the single page app
|
||||
this.express.get("*", (request, response) => {
|
||||
response.status(301)
|
||||
response.redirect('/')
|
||||
@@ -187,6 +190,8 @@ implements TableDefinitionExporter, IAdmin {
|
||||
this.httpServer.listen(port, () => {
|
||||
logger.info('Admin panel listening for HTTP on *'+port)
|
||||
})
|
||||
|
||||
/* */
|
||||
}
|
||||
|
||||
private stopWebserver(){
|
||||
|
||||
Reference in New Issue
Block a user