aboutsummaryrefslogtreecommitdiffstats
path: root/mascara/server.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-04-05 13:45:39 +0800
committerkumavis <aaron@kumavis.me>2017-04-05 13:45:39 +0800
commit0cfad78f5decbce04a7fa56e8f80e4fcecd12a79 (patch)
tree79c9198d5ad9db830233c2550eb73ed5e3793460 /mascara/server.js
parent8b146663483849cb76219bbf610c9ff6c5add68d (diff)
downloadtangerine-wallet-browser-0cfad78f5decbce04a7fa56e8f80e4fcecd12a79.tar
tangerine-wallet-browser-0cfad78f5decbce04a7fa56e8f80e4fcecd12a79.tar.gz
tangerine-wallet-browser-0cfad78f5decbce04a7fa56e8f80e4fcecd12a79.tar.bz2
tangerine-wallet-browser-0cfad78f5decbce04a7fa56e8f80e4fcecd12a79.tar.lz
tangerine-wallet-browser-0cfad78f5decbce04a7fa56e8f80e4fcecd12a79.tar.xz
tangerine-wallet-browser-0cfad78f5decbce04a7fa56e8f80e4fcecd12a79.tar.zst
tangerine-wallet-browser-0cfad78f5decbce04a7fa56e8f80e4fcecd12a79.zip
mascara - rename things + break out mascara asset server
Diffstat (limited to 'mascara/server.js')
-rw-r--r--mascara/server.js103
1 files changed, 0 insertions, 103 deletions
diff --git a/mascara/server.js b/mascara/server.js
deleted file mode 100644
index 67c89f11b..000000000
--- a/mascara/server.js
+++ /dev/null
@@ -1,103 +0,0 @@
-const express = require('express')
-const browserify = require('browserify')
-const watchify = require('watchify')
-const babelify = require('babelify')
-
-const zeroBundle = createBundle('./src/mascara.js')
-const controllerBundle = createBundle('./src/dapp-connection.js')
-const popupBundle = createBundle('./src/popup.js')
-const swBuild = createBundle('./src/background.js')
-
-const appBundle = createBundle('./example/index.js')
-
-//
-// Iframe Server
-//
-
-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)
-})
-iframeServer.get('/popup/sw-build.js', function(req, res){
- console.log('/sw-build.js')
- res.setHeader('Content-Type', 'application/javascript')
- res.send(swBuild.latest)
-})
-
-// serve background controller
-iframeServer.use(express.static('./server'))
-
-// start the server
-const mascaraPort = 9001
-iframeServer.listen(mascaraPort)
-console.log(`Mascara service listening on port ${mascaraPort}`)
-
-
-//
-// Dapp Server
-//
-
-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'))
-
-// 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 = {}
-
- var bundler = browserify({
- entries: [entryPoint],
- cache: {},
- packageCache: {},
- plugin: [watchify],
- })
-
- 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()
- })
- }
-
-}