Skip to content

Commit b7de212

Browse files
committed
proxy test
1 parent 6a988f1 commit b7de212

File tree

8 files changed

+45
-14
lines changed

8 files changed

+45
-14
lines changed

.github/workflows/github-pages.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- name: Checkout 🛎️
1111
uses: actions/checkout@v2.3.1
1212

13-
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
13+
- name: Install and Build 🔧
1414
run: |
1515
npm install
1616
npm run build

.github/workflows/proxy.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Proxy server setup
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
proxy-server-setup:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout 🛎️
11+
uses: actions/checkout@v2.3.1
12+
13+
- name: Install and Run proxy 🔧
14+
run: |
15+
npm install
16+
npm run proxy
File renamed without changes.

index.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
const express = require('express')
2-
const app = express()
1+
const { app } = require('./lib/server.js')
32
const helmet = require('helmet')
4-
const compression = require('compression')
5-
const port = process.env.PORT || 8080
6-
const netApi = require('@misioxd/net-browserify')
7-
const webpack = require('webpack')
83
const middleware = require('webpack-dev-middleware')
94
const devconfig = require('./src/webpack.dev.js')
5+
const compression = require('compression')
6+
const webpack = require('webpack')
107
const compiler = webpack(devconfig)
118

12-
app.use(helmet({ contentSecurityPolicy: false }))
139
app.use(compression())
14-
app.use(netApi({ allowOrigin: '*' }))
10+
app.use(helmet({ contentSecurityPolicy: false }))
1511
app.use(middleware(compiler))
16-
17-
app.listen(port, function () {
18-
return console.log(`Server is running on \x1b[34m*:${port}\x1b[0m`)
19-
})

lib/proxy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const { port } = require('./server.js')
2+
const { exec } = require('child_process')
3+
4+
exec(`./bin/pgrok -log=stdout -subdomain=web-minecraft-proxy ${port}`)

lib/server.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const express = require('express')
2+
const app = express()
3+
const netApi = require('@misioxd/net-browserify')
4+
const port = process.env.PORT || 8080
5+
6+
app.use(netApi({ allowOrigin: '*' }))
7+
8+
app.listen(port, () => {
9+
console.log(`Server is running on \x1b[34m*:${port}\x1b[0m`)
10+
})
11+
12+
module.exports = { app, port }

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"clean": "rimraf src/dist/*",
1010
"lint": "standard",
1111
"lint:fix": "standard --fix",
12-
"postinstall": "node lib/postinstall.js"
12+
"postinstall": "node lib/postinstall.js",
13+
"proxy": "node lib/proxy.js"
1314
},
1415
"license": "MIT",
1516
"repository": {
@@ -31,6 +32,7 @@
3132
"ansi-to-html": "^0.6.14",
3233
"bootstrap": "^4.6.0",
3334
"canvas": "^2.6.1",
35+
"child_process": "^1.0.2",
3436
"compression": "^1.7.4",
3537
"decompress": "^4.2.1",
3638
"decompress-tarxz": "^3.0.0",

0 commit comments

Comments
 (0)