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
|
||||
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() {
|
||||
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) {
|
||||
for (const message of results.logs) {
|
||||
|
@ -1,8 +1,11 @@
|
||||
export function createWebSocket() {
|
||||
try {
|
||||
return new WebSocket("ws://localhost:3000/chat-service");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
throw e;
|
||||
let appUrl = process.env.APP_URL;
|
||||
|
||||
if (appUrl.includes('localhost')) {
|
||||
appUrl = `//${appUrl}/chat-service`;
|
||||
} 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({
|
||||
fetch: app.fetch,
|
||||
port: parseInt(process.env.APP_PORT as string) || 3000,
|
||||
websocket
|
||||
});
|
||||
|
@ -1721,7 +1721,13 @@ var import_mithril = __toESM(require_mithril(), 1);
|
||||
|
||||
// frontend/websocket.js
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user