Skip to content

Commit db848a8

Browse files
committed
Update proxmox launcher
1 parent dd08e3d commit db848a8

File tree

18 files changed

+141
-213
lines changed

18 files changed

+141
-213
lines changed

.github/workflows/proxmox-launchpad.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ on:
77

88
jobs:
99
manage-container:
10-
runs-on: self-hosted # Use your runner label here
10+
runs-on: self-hosted # Use your runner label here
1111
steps:
1212
- uses: maxklema/proxmox-launchpad@main
1313
with:
1414
proxmox_username: ${{ secrets.PROXMOX_USERNAME }}
1515
proxmox_password: ${{ secrets.PROXMOX_PASSWORD }}
1616

1717
project_root: ""
18-
install_command: "deno install; deno task --recursive build"
18+
install_command: "sudo apt install -y unzip && curl -fsSL https://deno.land/install.sh | sudo bash -s -- -y && cp /root/.deno/bin/deno /usr/bin && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sudo bash -s -- -y && deno install && deno task --recursive build"
1919
start_command: "deno task --filter example-server-hono start"
2020
runtime_language: "nodejs"

deno.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"examples/example-server-hono",
1818
"examples/example-vue",
1919
"examples/example-vue-custom-element",
20-
"examples/example-proxmox-launchpad",
2120
"examples/mcptest"
2221
],
2322
"compilerOptions": {
@@ -33,7 +32,7 @@
3332

3433
"prosemirror-state": "npm:[email protected]",
3534
"prosemirror-view": "npm:[email protected]",
36-
"prosemirror-model": "npm:[email protected].2",
35+
"prosemirror-model": "npm:[email protected].3",
3736
"prosemirror-transform": "npm:[email protected]",
3837
"prosemirror-history": "npm:[email protected]",
3938

deno.lock

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

examples/example-server-hono/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "example-server-hono",
33
"tasks": {
4-
"dev": "deno test --allow-net --allow-ffi --allow-read --watch ./src/*.ts",
4+
"dev": "deno run --allow-net --allow-ffi --allow-read --allow-env --allow-sys --allow-write --allow-run --unstable-detect-cjs --node-modules-dir ./src/dev.ts",
55
"start": "deno run --allow-net --allow-ffi --allow-read --allow-env --allow-sys --allow-write --allow-run --unstable-detect-cjs --node-modules-dir ./src/main.ts"
66
},
77
"license": "MIT",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../example-vue/dist
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../example-vue-custom-element/dist
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Hello, World!</title>
7+
</head>
8+
<body>
9+
<a href="/examples/example-vue-custom-element"
10+
>/examples/example-vue-custom-element</a>
11+
</body>
12+
</html>

examples/example-server-hono/src/app.ts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ import { HonoYjsMemAdapter } from '@kerebron/extension-server-hono/HonoYjsMemAda
77

88
const __dirname = import.meta.dirname;
99

10-
const app = new Hono();
11-
1210
const yjsAdapter = new HonoYjsMemAdapter();
1311

1412
export class Server {
1513
public app;
1614
public fetch;
1715

18-
constructor(private opts: { devProxyUrl?: string } = {}) {
16+
constructor(private opts: { devProxyUrls: Record<string, string> } = { devProxyUrls: {} }) {
17+
const app = new Hono();
1918
this.app = app;
2019
this.fetch = app.fetch;
2120

@@ -31,29 +30,41 @@ export class Server {
3130
}),
3231
);
3332

34-
if (opts.devProxyUrl) {
35-
this.app.get('*', (c) => {
33+
for (const path in this.opts.devProxyUrls) {
34+
const devProxyUrl = this.opts.devProxyUrls[path];
35+
console.log(`Proxy: ${path} => ${devProxyUrl}`);
36+
this.app.all(path + '/*', (c) => {
3637
const queryString = c.req.url
3738
.split('?')
3839
.map((e: string, idx: number) => {
3940
return idx > 0 ? e : '';
4041
})
4142
.join('?');
42-
return proxy(`${opts.devProxyUrl}${c.req.path}${queryString}`);
43-
});
44-
} else {
45-
this.app.notFound((c) => {
46-
const file = Deno.readFileSync(
47-
__dirname + '/../../example-vue/dist/index.html',
48-
);
49-
return c.html(new TextDecoder().decode(file));
43+
44+
const subPath = c.req.path;
45+
return proxy(`${devProxyUrl}${subPath}${queryString}`, {
46+
...c.req, // optional, specify only when forwarding all the request data (including credentials) is necessary.
47+
headers: {
48+
...c.req.header(),
49+
'X-Forwarded-For': '127.0.0.1',
50+
'X-Forwarded-Host': c.req.header('host'),
51+
Authorization: undefined, // do not propagate request headers contained in c.req.header('Authorization')
52+
},
53+
});
5054
});
51-
this.app.use(
52-
'*',
53-
serveStatic({ root: __dirname + '/../../example-vue/dist' }),
54-
);
5555
}
5656

57+
this.app.notFound((c) => {
58+
const file = Deno.readFileSync(
59+
__dirname + '/../public/index.html',
60+
);
61+
return c.html(new TextDecoder().decode(file));
62+
});
63+
this.app.use(
64+
'*',
65+
serveStatic({ root: __dirname + '/../public' }),
66+
);
67+
5768
this.app.use('/*', cors());
5869
}
5970
}

examples/proxmox-launchpad/src/main.ts renamed to examples/example-server-hono/src/dev.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ const __dirname = import.meta.dirname;
66
// const viteDevServer = null;
77
const viteDevServer = await createViteServer({
88
// any valid user config options, plus `mode` and `configFile`
9-
configFile: __dirname + '/../../example-vue/vite.config.ts',
10-
root: __dirname + '/../../example-vue',
9+
base: '/examples/example-vue-custom-element',
10+
configFile: __dirname + '/../../example-vue-custom-element/vite.config.ts',
11+
root: __dirname + '/../../example-vue-custom-element',
1112
server: {
1213
// middlewareMode: true
1314
port: 1337,
@@ -16,5 +17,5 @@ const viteDevServer = await createViteServer({
1617
});
1718
await viteDevServer.listen();
1819

19-
const server = new Server({ devProxyUrl: 'http://localhost:1337' });
20+
const server = new Server({ devProxyUrls: { '/examples/example-vue-custom-element': 'http://localhost:1337' } });
2021
Deno.serve(server.fetch);
Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
import { Server } from './app.ts';
2-
import { createServer as createViteServer } from 'npm:vite';
32

43
const __dirname = import.meta.dirname;
54

6-
// const viteDevServer = null;
7-
const viteDevServer = await createViteServer({
8-
// any valid user config options, plus `mode` and `configFile`
9-
configFile: __dirname + '/../../example-vue/vite.config.ts',
10-
root: __dirname + '/../../example-vue',
11-
server: {
12-
// middlewareMode: true
13-
port: 1337,
14-
},
15-
// appType: 'custom'
16-
});
17-
await viteDevServer.listen();
18-
19-
const server = new Server({ devProxyUrl: 'http://localhost:1337' });
20-
Deno.serve(server.fetch);
5+
const server = new Server();
6+
Deno.serve({ port: 80 }, server.fetch);

0 commit comments

Comments
 (0)