manuals, deploy, docs
This commit is contained in:
@@ -7,6 +7,7 @@ import { fileURLToPath } from 'url';
|
||||
class App{
|
||||
constructor(){
|
||||
this.root = path.resolve(dirname(fileURLToPath(import.meta.url)) + '/../../');
|
||||
console.log('App root is set to', this.root);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
|
||||
const pe = process.env;
|
||||
/**
|
||||
* Configuration class
|
||||
*/
|
||||
@@ -54,13 +54,13 @@ class Config{
|
||||
* @type {boolean}
|
||||
* @memberof SiteOptions
|
||||
*/
|
||||
ssl: true,
|
||||
ssl: !!parseInt(pe.SRV_SSL),
|
||||
|
||||
/** Port to use
|
||||
* @type {Number}
|
||||
* @memberof SiteOptions
|
||||
*/
|
||||
port: 3000,
|
||||
port: pe.SRV_PORT,
|
||||
|
||||
/**
|
||||
* @class Certificate data
|
||||
|
||||
@@ -73,25 +73,13 @@ class WebServer {
|
||||
* @param {App} app The application instance
|
||||
*/
|
||||
async start(app) {
|
||||
let indexFile = app.root + '/index.html';
|
||||
|
||||
let indexFileContent = fs.readFileSync(indexFile, { encoding: 'utf-8' });
|
||||
|
||||
function index(req, res) {
|
||||
//res.sendFile(indexFile);
|
||||
res.send(indexFileContent.replace(/\#NONCE\#/g, res.locals.cspNonce));
|
||||
}
|
||||
|
||||
this.xapp.get('/', index);
|
||||
|
||||
// app.config.langs.forEach(l => {
|
||||
// this.xapp.use('/' + l.code, index);
|
||||
// })
|
||||
|
||||
this.xapp.use(express.static(`${this.app.root}/dist/`));
|
||||
|
||||
this.xapp.use(express.static(`${this.app.root}/frontend/`));
|
||||
|
||||
this.xapp.use((req, res, next) => {
|
||||
if (req.method == 'GET' || req.method == 'POST') {
|
||||
if (req.method == 'GET'){
|
||||
res.sendFile(`${this.app.root}/frontend/index.html`);
|
||||
}else if (req.method == 'POST') {
|
||||
return res.status(404).end();
|
||||
} else next();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user