Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// SERVER SIDE APP
// ==============================================================
'use strict';
require('mithril/test-utils/browserMock')(global);
global.window.XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest;
const server = require('./app/server');
const port = process.env.PORT || 3000;
server.listen(port, () => {
console.log('Listening on localhost:' + port + '...');
});
_.defaults(sscConfig, {base_url: process.env.NODE_BASE_URL, assets_url: 'file://' + __dirname + '/../server/static'});
}
global.window.globals = sscConfig;
console.log('Configuration', sscConfig);
var STK = require('sstk-core');
// Indicate that we are not on the browser
STK.Constants.isBrowser = false;
//console.log('baseUrl is ' + STK.Constants.baseUrl);
//console.log('assetsDir is ' + STK.Constants.assetsDir);
// Who uses the XMLHttpRequest? ColladaLoader and _.getJSON
if (STK.Constants.baseUrl.startsWith('http:') || STK.Constants.baseUrl.startsWith('https:') ) {
// NOTE: Don't support file://
global.XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest;
} else {
// NOTE: Don't post response in event!!!
global.XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
}
STK.ImageUtil.getPixelsSync = deasync(getPixels);
var AssetGroups = STK.assets.AssetGroups;
var AssetsDb = STK.assets.AssetsDb;
var cachedFileLoader = new STK.assets.CachedAssetLoader({
assetCacheSize: sscConfig.fileCache.size,
loadFn: function (loadOpts, callback) {
//console.log('load ' + loadOpts.url + ', ' + this.responseType);
fs.readAsync(loadOpts.url, loadOpts.encoding || 'utf8', callback);
}
});
'use strict'
require('mithril/test-utils/browserMock')(global)
global.window.XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest
var express = require('express')
var bodyParser = require('body-parser')
var web = require('./server/web')
var rest = require('./server/rest')
var compression = require('compression')
var browserify = require('browserify-middleware')
var app = express()
app.use(
bodyParser.urlencoded({
extended: true,
})
)
app.use(bodyParser.raw())
require('mithril/test-utils/browserMock')(global)
global.window.XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest