Build and replace envvars, run on local transport
This commit is contained in:
parent
29e442677b
commit
186ca13025
2
chat-app/.env.sample
Normal file
2
chat-app/.env.sample
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
APP_URL="chat.freedoom.party"
|
||||||
|
APP_PORT=3000
|
1
chat-app/.gitignore
vendored
1
chat-app/.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
# deps
|
# deps
|
||||||
node_modules/
|
node_modules/
|
||||||
|
.env
|
||||||
|
0
chat-app/Dockerfile
Normal file
0
chat-app/Dockerfile
Normal file
@ -11,7 +11,13 @@ async function fileExists(path: string): Promise<bool> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const results = await Bun.build({ ...config, verbose: true });
|
const results = await Bun.build({
|
||||||
|
...config,
|
||||||
|
verbose: true,
|
||||||
|
define: {
|
||||||
|
'process.env.APP_URL': process.env.APP_URL,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (!results.success) {
|
if (!results.success) {
|
||||||
for (const message of results.logs) {
|
for (const message of results.logs) {
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
export function createWebSocket() {
|
export function createWebSocket() {
|
||||||
try {
|
let appUrl = process.env.APP_URL;
|
||||||
return new WebSocket("ws://localhost:3000/chat-service");
|
|
||||||
} catch (e) {
|
if (appUrl.includes('localhost')) {
|
||||||
console.error(e);
|
appUrl = `//${appUrl}/chat-service`;
|
||||||
throw e;
|
} else {
|
||||||
|
appUrl = `//${appUrl}/chat-service`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new WebSocket(appUrl);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
build:
|
|
||||||
bun build.ts
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -r static/js/*
|
|
||||||
|
|
||||||
test:
|
|
||||||
bun test
|
|
@ -59,5 +59,6 @@ app.use("/*", serveStatic({ root: "/static" }));
|
|||||||
|
|
||||||
Bun.serve({
|
Bun.serve({
|
||||||
fetch: app.fetch,
|
fetch: app.fetch,
|
||||||
|
port: parseInt(process.env.APP_PORT as string) || 3000,
|
||||||
websocket
|
websocket
|
||||||
});
|
});
|
||||||
|
@ -1721,7 +1721,13 @@ var import_mithril = __toESM(require_mithril(), 1);
|
|||||||
|
|
||||||
// frontend/websocket.js
|
// frontend/websocket.js
|
||||||
function createWebSocket() {
|
function createWebSocket() {
|
||||||
return new WebSocket("ws://localhost:3000/chat-service");
|
let appUrl = "localhost:3000";
|
||||||
|
if (appUrl.includes("localhost")) {
|
||||||
|
appUrl = `//${appUrl}/chat-service`;
|
||||||
|
} else {
|
||||||
|
appUrl = `//${appUrl}/chat-service`;
|
||||||
|
}
|
||||||
|
return new WebSocket(appUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// frontend/index.js
|
// frontend/index.js
|
||||||
|
Loading…
Reference in New Issue
Block a user