Refactor api.js into web_api, which encapsulates all web access

This commit is contained in:
Scott Nonnenberg 2018-05-25 18:01:56 -07:00
parent 37ebe9fcec
commit f3bd0cf903
16 changed files with 763 additions and 577 deletions

View file

@ -82,7 +82,15 @@ if (window.config.proxyUrl) {
}
window.nodeSetImmediate = setImmediate;
window.nodeWebSocket = require('websocket').w3cwebsocket;
const { initialize: initializeWebAPI } = require('./js/modules/web_api');
window.WebAPI = initializeWebAPI({
url: window.config.serverUrl,
cdnUrl: window.config.cdnUrl,
certificateAuthority: window.config.certificateAuthority,
proxyUrl: window.config.proxyUrl,
});
// Linux seems to periodically let the event loop stop, so this is a global workaround
setInterval(() => {
@ -100,10 +108,6 @@ window.libphonenumber = require('google-libphonenumber').PhoneNumberUtil.getInst
window.libphonenumber.PhoneNumberFormat = require('google-libphonenumber').PhoneNumberFormat;
window.loadImage = require('blueimp-load-image');
window.nodeBuffer = Buffer;
window.nodeFetch = require('node-fetch');
window.ProxyAgent = require('proxy-agent');
// Note: when modifying this file, consider whether our React Components or Backbone Views
// will need these things to render in the Style Guide. If so, go update one of these
// two locations: