aboutsummaryrefslogtreecommitdiffstats
path: root/mascara/server/index.js
blob: 24739b43f9d462a8288e5a10be332850e7949639 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const express = require('express')
const createBundle = require('./util').createBundle
const serveBundle = require('./util').serveBundle

module.exports = createMetamascaraServer


function createMetamascaraServer () {

  // start bundlers
  const metamascaraBundle = createBundle(__dirname + '/../src/mascara.js')
  const proxyBundle = createBundle(__dirname + '/../src/proxy.js')
  const uiBundle = createBundle(__dirname + '/../src/ui.js')
  const backgroundBuild = createBundle(__dirname + '/../src/background.js')

  // serve bundles
  const server = express()
  // ui window
  serveBundle(server, '/ui.js', uiBundle)
  server.use(express.static(__dirname + '/../ui/', { setHeaders: (res) => res.set('X-Frame-Options', 'DENY') }))
  server.use(express.static(__dirname + '/../../dist/chrome'))
  // metamascara
  serveBundle(server, '/metamascara.js', metamascaraBundle)
  // proxy
  serveBundle(server, '/proxy/proxy.js', proxyBundle)
  server.use('/proxy/', express.static(__dirname + '/../proxy'))
  // background
  serveBundle(server, '/background.js', backgroundBuild)

  return server

}