From b7aab955196a7cef2705e8546814b5c6c1830da7 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 26 Aug 2016 17:39:19 -0700 Subject: library - basic test server + partial safari fixes --- library/server.js | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 library/server.js (limited to 'library/server.js') 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 -- cgit v1.2.3 From 81da958761ab7ae3976c7444528ba8d9bb0744c6 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 Aug 2016 19:15:20 -0700 Subject: Add a port log to server start --- library/server.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'library/server.js') diff --git a/library/server.js b/library/server.js index c7fea085f..16143e72b 100644 --- a/library/server.js +++ b/library/server.js @@ -49,9 +49,9 @@ dappServer.get('/app.js', function(req, res){ // serve static dappServer.use(express.static('./example')) - -dappServer.listen('9002') - +const dappPort = '9002' +dappServer.listen(dappPort) +console.log(`Dapp listening on port ${dappPort}`) function createBundle(entryPoint){ @@ -70,7 +70,7 @@ function createBundle(entryPoint){ global: true, presets: [bablePreset], }) - + bundler.on('update', bundle) bundle() @@ -85,4 +85,4 @@ function createBundle(entryPoint){ }) } -} \ No newline at end of file +} -- cgit v1.2.3 From a3330568d9aa68e2609ce875a96e784c2e77c20c Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 31 Aug 2016 15:33:24 -0700 Subject: various things --- library/server.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'library/server.js') diff --git a/library/server.js b/library/server.js index c7fea085f..6da9b2e0b 100644 --- a/library/server.js +++ b/library/server.js @@ -12,8 +12,6 @@ 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 @@ -31,8 +29,6 @@ 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() @@ -64,6 +60,7 @@ function createBundle(entryPoint){ plugin: [watchify], }) + // global transpile var bablePreset = path.resolve(__dirname, '../node_modules/babel-preset-es2015') bundler.transform(babelify, { -- cgit v1.2.3 From 5126ddaf0c25d243c625adff82dc95273acf1291 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 12 Sep 2016 19:48:39 -0700 Subject: mascara - server - prepare to serve popup --- library/server.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'library/server.js') diff --git a/library/server.js b/library/server.js index 7c764a4a7..495aba914 100644 --- a/library/server.js +++ b/library/server.js @@ -19,8 +19,10 @@ iframeServer.get('/controller.js', function(req, res){ res.send(controllerBundle.latest) }) -// serve static +// serve background controller iframeServer.use(express.static('./server')) +// serve popup window +// iframeServer.use('/popup', express.static('../dist/chrome')) iframeServer.listen('9001') -- cgit v1.2.3 From a4cdd198438816b99630adf7c30d28a8ec2a18bb Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 13 Sep 2016 00:31:04 -0700 Subject: mascara - everything but the popup bundle --- library/server.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'library/server.js') diff --git a/library/server.js b/library/server.js index 495aba914..033c65358 100644 --- a/library/server.js +++ b/library/server.js @@ -6,6 +6,7 @@ const path = require('path') const zeroBundle = createBundle('./index.js') const controllerBundle = createBundle('./controller.js') +// const popupBundle = createBundle('./popup.js') const appBundle = createBundle('./example/index.js') // @@ -14,6 +15,12 @@ const appBundle = createBundle('./example/index.js') const iframeServer = express() +// serve popup window +// iframeServer.get('/popup/scripts/popup.js', function(req, res){ +// res.send(popupBundle.latest) +// }) +iframeServer.use('/popup', express.static('../dist/chrome')) + // serve controller bundle iframeServer.get('/controller.js', function(req, res){ res.send(controllerBundle.latest) @@ -21,8 +28,7 @@ iframeServer.get('/controller.js', function(req, res){ // serve background controller iframeServer.use(express.static('./server')) -// serve popup window -// iframeServer.use('/popup', express.static('../dist/chrome')) + iframeServer.listen('9001') -- cgit v1.2.3 From 81d25d560f4920ee7a357881931e674bea97176c Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 13 Sep 2016 10:19:40 -0700 Subject: mascara - serve popup bundle --- library/server.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'library/server.js') diff --git a/library/server.js b/library/server.js index 033c65358..bb0b24e50 100644 --- a/library/server.js +++ b/library/server.js @@ -2,11 +2,10 @@ 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 popupBundle = createBundle('./popup.js') +const popupBundle = createBundle('./popup.js') const appBundle = createBundle('./example/index.js') // @@ -16,9 +15,9 @@ const appBundle = createBundle('./example/index.js') const iframeServer = express() // serve popup window -// iframeServer.get('/popup/scripts/popup.js', function(req, res){ -// res.send(popupBundle.latest) -// }) +iframeServer.get('/popup/scripts/popup.js', function(req, res){ + res.send(popupBundle.latest) +}) iframeServer.use('/popup', express.static('../dist/chrome')) // serve controller bundle @@ -29,8 +28,10 @@ iframeServer.get('/controller.js', function(req, res){ // serve background controller iframeServer.use(express.static('./server')) - -iframeServer.listen('9001') +// start the server +const mascaraPort = 9001 +iframeServer.listen(mascaraPort) +console.log(`Mascara service listening on port ${mascaraPort}`) // @@ -39,7 +40,6 @@ iframeServer.listen('9001') const dappServer = express() - // serve metamask-lib bundle dappServer.get('/zero.js', function(req, res){ res.send(zeroBundle.latest) @@ -53,10 +53,22 @@ dappServer.get('/app.js', function(req, res){ // serve static dappServer.use(express.static('./example')) +// start the server const dappPort = '9002' dappServer.listen(dappPort) console.log(`Dapp listening on port ${dappPort}`) +// +// util +// + +function serveBundle(entryPoint){ + const bundle = createBundle(entryPoint) + return function(req, res){ + res.send(bundle.latest) + } +} + function createBundle(entryPoint){ var bundleContainer = {} @@ -69,14 +81,14 @@ function createBundle(entryPoint){ }) // global transpile - var bablePreset = path.resolve(__dirname, '../node_modules/babel-preset-es2015') + var bablePreset = require.resolve('babel-preset-es2015') bundler.transform(babelify, { global: true, presets: [bablePreset], + babelrc: false, }) - bundler.on('update', bundle) bundle() -- cgit v1.2.3