This commit is contained in:
peter
2020-03-08 17:33:51 +01:00
parent b2707bb88f
commit 111656b9b4
14 changed files with 5010 additions and 13757 deletions
+22 -17
View File
@@ -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(){
+5 -3
View File
@@ -1,6 +1,7 @@
import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader';
/*
import { NgModule } from '../../frontend/node_modules/@angular/core';
import { ServerModule } from '../../frontend/node_modules/@angular/platform-server';
import { ModuleMapLoaderModule } from '../../frontend/node_modules/@nguniversal/module-map-ngfactory-loader';
import { AppModule } from '../../frontend/src/app/app.module';
import { AppComponent } from '../../frontend/src/app/app.component';
@@ -17,3 +18,4 @@ import { AppComponent } from '../../frontend/src/app/app.component';
bootstrap: [ AppComponent ],
})
export class AppServerModule {}
*/