Skip to content

Commit

Permalink
new(all): SSR enabled for test in PROD.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Feb 20, 2022
1 parent b5d99c3 commit 02898ad
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
21 changes: 16 additions & 5 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ export class GBMinService {
// SSR processing.

const defaultOptions = {
prerender: [],
exclude: ["/api/", "/instances/", "/webhooks/"],
useCache: true,
prerender: [],
exclude: ["/api/", "/instances/", "/webhooks/"],
useCache: true,
cacheRefreshRate: 86400
};
GBServer.globals.server.use(ssrForBots(defaultOptions));
Expand All @@ -156,6 +156,17 @@ export class GBMinService {
// default.gbui access definition.

GBServer.globals.server.use('/', express.static(url));
GBServer.globals.server.use('/ssr-delay', async (req,res) => {

const sleep = async ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
await sleep(10000);
res.status(200);
res.end();
});
}

// Servers the bot information object via HTTP so clients can get
Expand Down Expand Up @@ -336,9 +347,9 @@ export class GBMinService {
if (botId === '[default]' || botId === undefined) {
botId = GBConfigService.get('BOT_ID');
}

GBLog.info(`Client requested instance for: ${botId}.`);


// Processes group behaviour.

Expand Down
2 changes: 2 additions & 0 deletions packages/default.gbui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="shortcut icon" href="%PUBLIC_URL%/ssrdelay">

<link rel="stylesheet" type="text/css" href="./css/pragmatismo.css" />
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<title>General Bots Community Edition | pragmatismo.io</title>
Expand Down
20 changes: 10 additions & 10 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,19 @@ export class GBServer {
};
if (process.env.CERTIFICATE_PFX) {
var options = {
passphrase: process.env.CERTIFICATE_PASSPHRASE ,
passphrase: process.env.CERTIFICATE_PASSPHRASE,
pfx: fs.readFileSync(process.env.CERTIFICATE_PFX)
};
};
const httpsServer = https.createServer(options, server).listen(port, mainCallback);
const httpsServer = https.createServer(options, server).listen(port, mainCallback);

if (process.env.CERTIFICATE2_PFX) {
var options = {
passphrase: process.env.CERTIFICATE2_PASSPHRASE ,
pfx: fs.readFileSync(process.env.CERTIFICATE2_PFX)
};
httpsServer.addContext(process.env.CERTIFICATE2_DOMAIN, options);

if (process.env.CERTIFICATE2_PFX) {
var options = {
passphrase: process.env.CERTIFICATE2_PASSPHRASE,
pfx: fs.readFileSync(process.env.CERTIFICATE2_PFX)
};
httpsServer.addContext(process.env.CERTIFICATE2_DOMAIN, options);

}
}
else {
server.listen(port, mainCallback);
Expand Down

0 comments on commit 02898ad

Please sign in to comment.