Make server side rendering fully configurable
parent
961b5fe648
commit
95837beaf7
14
src/http.ts
14
src/http.ts
|
@ -12,9 +12,6 @@ import * as chatInteg from "./chat";
|
||||||
import { config } from "./config";
|
import { config } from "./config";
|
||||||
import { readdir, readFileSync, writeFileSync } from "fs";
|
import { readdir, readFileSync, writeFileSync } from "fs";
|
||||||
import { JWT, JWK } from "jose";
|
import { JWT, JWK } from "jose";
|
||||||
import { strict } from "assert";
|
|
||||||
import { parse } from "path";
|
|
||||||
import { isBuffer } from "util";
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
@ -55,12 +52,15 @@ async function init(){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
app.disable('x-powered-by');
|
app.disable('x-powered-by');
|
||||||
//site handlers
|
//server-side site routes
|
||||||
//await initSite(config['satyr']['registration']);
|
if(config['http']['server_side_render'])
|
||||||
//api handlers
|
await initSite(config['satyr']['registration']);
|
||||||
|
//api routes
|
||||||
await initAPI();
|
await initAPI();
|
||||||
//static files if nothing else matches first
|
//static files if nothing else matches
|
||||||
app.use(express.static(config['http']['directory']));
|
app.use(express.static(config['http']['directory']));
|
||||||
|
//client-side site routes
|
||||||
|
if(!config['http']['server_side_render'])
|
||||||
await initFE();
|
await initFE();
|
||||||
//404 Handler
|
//404 Handler
|
||||||
app.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
|
|
Reference in New Issue