forked from auth0-extensions/auth0-account-link-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webtask.js
21 lines (18 loc) · 812 Bytes
/
webtask.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const tools = require('auth0-extension-hapi-tools');
const hapiApp = require('./server/init');
const logger = require('./lib/logger');
const config = require('./lib/config');
const createServer = tools.createServer((wtConfig, wtStorage) => {
console.log('micah webtask.js console log');
logger.info('[micah] Starting Account Link Extension - Version:', process.env.CLIENT_VERSION);
logger.info(' > WT_URL:', wtConfig('WT_URL'));
logger.info(' > PUBLIC_WT_URL:', wtConfig('PUBLIC_WT_URL'));
return hapiApp(wtConfig, wtStorage);
});
module.exports = (context, req, res) => {
const publicUrl = (req.x_wt && req.x_wt.ectx && req.x_wt.ectx.PUBLIC_WT_URL) || false;
if (!publicUrl) {
config.setValue('PUBLIC_WT_URL', tools.urlHelpers.getWebtaskUrl(req));
}
createServer(context, req, res);
};