aboutsummaryrefslogtreecommitdiffstats
path: root/library/server.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-08-27 08:39:19 +0800
committerkumavis <aaron@kumavis.me>2016-08-27 08:39:19 +0800
commitb7aab955196a7cef2705e8546814b5c6c1830da7 (patch)
tree19c1b72359af5372bb800b2e268ce7f146ddb915 /library/server.js
parent23a144fb8b0b214b9c352ee523405d5ecd03046e (diff)
downloadtangerine-wallet-browser-b7aab955196a7cef2705e8546814b5c6c1830da7.tar
tangerine-wallet-browser-b7aab955196a7cef2705e8546814b5c6c1830da7.tar.gz
tangerine-wallet-browser-b7aab955196a7cef2705e8546814b5c6c1830da7.tar.bz2
tangerine-wallet-browser-b7aab955196a7cef2705e8546814b5c6c1830da7.tar.lz
tangerine-wallet-browser-b7aab955196a7cef2705e8546814b5c6c1830da7.tar.xz
tangerine-wallet-browser-b7aab955196a7cef2705e8546814b5c6c1830da7.tar.zst
tangerine-wallet-browser-b7aab955196a7cef2705e8546814b5c6c1830da7.zip
library - basic test server + partial safari fixes
Diffstat (limited to 'library/server.js')
-rw-r--r--library/server.js88
1 files changed, 88 insertions, 0 deletions
diff --git a/library/server.js b/library/server.js
new file mode 100644
index 000000000..c7fea085f
--- /dev/null
+++ b/library/server.js
@@ -0,0 +1,88 @@
+const express = require('express')
+const browserify = require('browserify')
+const watchify = require('watchify')
+const babelify = require('babelify')
+const path = require('path')
+
+const zeroBundle = createBundle('./index.js')
+const controllerBundle = createBundle('./controller.js')
+const appBundle = createBundle('./example/index.js')
+
+//
+// Iframe Server
+//
+
+// beefy frame.js:bundle.js 9001 --live -- -t [ babelify --global --presets [ es2015 ] ]
+
+const iframeServer = express()
+
+// serve controller bundle
+iframeServer.get('/controller.js', function(req, res){
+ res.send(controllerBundle.latest)
+})
+
+// serve static
+iframeServer.use(express.static('./server'))
+
+iframeServer.listen('9001')
+
+
+//
+// Dapp Server
+//
+
+// beefy example/index.js:bundle.js index.js:zero.js --cwd example/ 9002 --live --open -- -t [ babelify --global --presets [ es2015 ] ]
+
+const dappServer = express()
+
+
+// serve metamask-lib bundle
+dappServer.get('/zero.js', function(req, res){
+ res.send(zeroBundle.latest)
+})
+
+// serve dapp bundle
+dappServer.get('/app.js', function(req, res){
+ res.send(appBundle.latest)
+})
+
+// serve static
+dappServer.use(express.static('./example'))
+
+
+dappServer.listen('9002')
+
+
+function createBundle(entryPoint){
+
+ var bundleContainer = {}
+
+ var bundler = browserify({
+ entries: [entryPoint],
+ cache: {},
+ packageCache: {},
+ plugin: [watchify],
+ })
+
+ var bablePreset = path.resolve(__dirname, '../node_modules/babel-preset-es2015')
+
+ bundler.transform(babelify, {
+ global: true,
+ presets: [bablePreset],
+ })
+
+
+ bundler.on('update', bundle)
+ bundle()
+
+ return bundleContainer
+
+ function bundle() {
+ bundler.bundle(function(err, result){
+ if (err) throw err
+ console.log(`Bundle updated! (${entryPoint})`)
+ bundleContainer.latest = result.toString()
+ })
+ }
+
+} \ No newline at end of file