1
0

It is running,b ut not yet letting you chat

Signed-off-by: James Ketrenos <james@ketrenos.com>
This commit is contained in:
James Ketrenos 2023-03-30 18:29:34 -07:00
parent 29de35b17f
commit 269081b565
14 changed files with 425 additions and 382 deletions

1
.env
View File

@ -1,4 +1,3 @@
HOST=localhost
HTTPS=true
DANGEROUSLY_DISABLE_HOST_CHECK='true'
WDS_SOCKET_PORT=0

View File

@ -68,9 +68,10 @@ COPY /.env /home/user/.env
RUN { \
echo "REACT_APP_CHAT_URL=${CHAT_URL}" ; \
echo "REACT_APP_CHAT_BASE=${CHAT_BASE}" ; \
echo "WDS_SOCKET_PATH=${CHAT_BASE}/ws" ; \
echo "PUBLIC_URL=${CHAT_BASE}" ; \
echo "WDS_SOCKET_PATH=/ws" ; \
echo "WDS_SOCKET_HOST=${CHAT_URL#http*://}" ; \
echo "WDS_SOCKET_PORT=443" ; \
} | tee -a /home/user/.env
COPY /server /home/user/server

View File

@ -12,10 +12,10 @@
"@emotion/styled": "^11.10.6",
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.11.15",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.11",
"@types/react": "^18.0.31",
"@types/react-dom": "^18.0.11",
"@types/jest": "^29.2.3",
"@types/node": "^18.11.10",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"fast-deep-equal": "^3.1.3",
"history": "^5.3.0",
"http-proxy-middleware": "^2.0.6",
@ -30,8 +30,7 @@
"react-router-dom": "^6.4.4",
"react-scripts": "^5.0.1",
"react-select": "^5.7.0",
"react-spinners": "^0.13.6",
"typescript": "^5.0.3"
"react-spinners": "^0.13.6"
}
},
"node_modules/@ampproject/remapping": {
@ -16415,15 +16414,16 @@
}
},
"node_modules/typescript": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.3.tgz",
"integrity": "sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==",
"version": "4.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=12.20"
"node": ">=4.2.0"
}
},
"node_modules/unbox-primitive": {

View File

@ -1,4 +1,6 @@
.App {
display: flex;
flex-direction: row;
text-align: center;
}
@ -13,6 +15,24 @@
}
}
.Conference {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow-y: auto;
display: flex;
flex-direction: row;
text-align: center;
}
.Sidebar {
display: flex;
border: 1px solid black;
min-width: 10vwh;
}
.App-header {
background-color: #282c34;
min-height: 100vh;

View File

@ -10,6 +10,7 @@ import {
import { GlobalContext, GlobalData } from "./GlobalContext";
import { PersonList } from "./PersonList";
import { Chat } from "./Chat";
import { Actions } from "./Actions";
import "./App.css";
import equal from "fast-deep-equal";
@ -17,7 +18,7 @@ import equal from "fast-deep-equal";
// @ts-ignore
const base = process.env.REACT_APP_CHAT_BASE;
const Table = () => {
const Conference = () => {
const params = useParams();
const [chatId, setChatId] = useState(params.chatId ? params.chatId : undefined);
const [ws, setWs] = useState <WebSocket | undefined>(); /* tracks full websocket lifetime */
@ -299,8 +300,10 @@ const Table = () => {
return <GlobalContext.Provider value={global}>
{ /* <PingPong/> */}
<div className="Table">
<div>Test</div>
<div className="Conference">
<div className="Sidebar">
{name === "" && <Actions/>}
{name !== "" && <PersonList />}
{name !== "" && <Chat />}
</div>
@ -313,6 +316,7 @@ const App = () => {
const [error, setError] = useState<string>('');
useEffect(() => {
console.log(personId, base);
if (personId) {
return;
}
@ -325,16 +329,17 @@ const App = () => {
},
}).then((res) => {
if (res.status >= 400) {
const error = `Unable to connect to Ketr Ketran chat server! ` +
const error = `Unable to connect to Ketr Chat server! ` +
`Try refreshing your browser in a few seconds.`;
console.error(error);
setError(error);
}
console.log(res.headers);
return res.json();
}).then((data) => {
console.log(data);
setPersonId(data.person);
}).catch((error) => {
console.error(error);
});
}, [personId, setPersonId]);
@ -345,8 +350,8 @@ const App = () => {
return (
<Router>
<Routes>
<Route element={<Table />} path={`${base}/:chatId`} />
<Route element={<Table />} path={`${base}`} />
<Route element={<Conference />} path={`${base}/:chatId`} />
<Route element={<Conference />} path={`${base}`} />
</Routes>
</Router>
);

View File

@ -2,7 +2,7 @@ version: '3.1'
services:
ketr.chat:
volumes:
- /etc/nginx/ssl:/etc/nginx/ssl:ro # Use host web keys
- /etc/letsencrypt:/etc/letsencrypt:ro # Use host web keys
- ./logs:/home/user/logs #
- ./db:/home/user/db
# Hot mount client and server for dynamic changes in DEVELOPMENT
@ -21,5 +21,5 @@ services:
- ./client/public:/home/user/client/public
- ./client/src:/home/user/client/src
ports:
- 127.0.0.1:19876:80 # Main app entrypoint
- 127.0.0.1:19876:443 # Main app entrypoint
- 127.0.0.1:14200:4200 # shellinabox

View File

@ -15,8 +15,6 @@ services:
volumes:
- /etc/nginx/ssl:/etc/nginx/ssl:ro # Use host web keys
- ./logs:/home/user/logs #
ports:
- 127.0.0.1:19876:80
ketr.chat-production:
image: ketr.chat:production
@ -31,8 +29,7 @@ services:
tty: true # Needed for react-scripts
restart: always
volumes:
- /etc/nginx/ssl:/etc/nginx/ssl:ro # Use host web keys
- /etc/letsencrypt:/etc/letsencrypt:ro # Use host web keys
- ./db:/home/user/db
ports:
- 127.0.0.1:19876:80

View File

@ -29,9 +29,7 @@ if [[ -z "${DEVELOPMENT}" ]]; then
else
echo "Running in DEVELOPMENT mode."
cd /home/user/server
npm install
{ while true; do npm start ; sleep 3 ; done ; } &
cd /home/user/client
npm install
{ while true; do npm start ; sleep 3 ; done ; }
fi

View File

@ -3,6 +3,8 @@ version: '3.1'
services:
ketr.chat-production:
volumes:
- /etc/nginx/ssl:/etc/nginx/ssl:ro # Use host web keys
- /etc/letsencrypt:/etc/letsencrypt:ro # Use host web keys
- ./logs:/home/user/logs #
- ./db:/home/user/db
ports:
- 127.0.0.1:19876:443 # Main app entrypoint

View File

@ -50,8 +50,8 @@ if (config.has("admin")) {
/* Allow loading of the app w/out being logged in */
app.use(basePath, index);
/* /chat loads the default index */
app.use(basePath + "chat", index);
/* /chats loads the default index */
app.use(basePath + "chats", index);
/* Allow access to the 'users' API w/out being logged in */
/*
@ -67,7 +67,7 @@ app.use(function(err, req, res, next) {
});
});
app.use(`${basePath}api/v1/chat`, require("./routes/chat"));
app.use(`${basePath}api/v1/chats`, require("./routes/chat"));
/* Declare the "catch all" index route last; the final route is a 404 dynamic router */
app.use(basePath, index);

View File

@ -1,4 +1,18 @@
# DEVELOPMENT -- use npm development server on port 3000 (entrypoint.sh)
location /ws/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass_header Set-Cookie;
proxy_pass_header P3P;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass https://localhost:3000/ws/;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@ -12,4 +26,3 @@ location / {
proxy_set_header Connection "upgrade";
proxy_pass https://localhost:3000/ketr.chat/;
}

View File

@ -1,4 +1,4 @@
let basePath = process.env.CHAT_BASE;
let basePath = "/";//process.env.CHAT_BASE;
console.log(basePath);
basePath = "/" + basePath.replace(/^\/+/, "").replace(/\/+$/, "") + "/";
if (basePath == "//") {

View File

@ -2,10 +2,13 @@ server {
root /home/user;
index index.html;
access_log /var/log/nginx/access.log;
error_log stderr;
listen 443 ssl;
autoindex on;
ssl_certificate /etc/letsencrypt/live/ketrenos.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ketrenos.com/privkey.pem;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# proxy_pass has automatic redirect from v1 -> v1/
# Set the API redirect early in case endpoints have similar names
@ -21,7 +24,7 @@ server {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://localhost:8911/api/v1/;
proxy_pass http://localhost:8930/api/v1/;
}
# Set tail-pre injection for log files

File diff suppressed because it is too large Load Diff