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 HOST=localhost
HTTPS=true HTTPS=true
DANGEROUSLY_DISABLE_HOST_CHECK='true' DANGEROUSLY_DISABLE_HOST_CHECK='true'
WDS_SOCKET_PORT=0

View File

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

View File

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

View File

@ -1,4 +1,6 @@
.App { .App {
display: flex;
flex-direction: row;
text-align: center; 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 { .App-header {
background-color: #282c34; background-color: #282c34;
min-height: 100vh; min-height: 100vh;

View File

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

View File

@ -2,7 +2,7 @@ version: '3.1'
services: services:
ketr.chat: ketr.chat:
volumes: 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 # - ./logs:/home/user/logs #
- ./db:/home/user/db - ./db:/home/user/db
# Hot mount client and server for dynamic changes in DEVELOPMENT # Hot mount client and server for dynamic changes in DEVELOPMENT
@ -21,5 +21,5 @@ services:
- ./client/public:/home/user/client/public - ./client/public:/home/user/client/public
- ./client/src:/home/user/client/src - ./client/src:/home/user/client/src
ports: 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 - 127.0.0.1:14200:4200 # shellinabox

View File

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

View File

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

View File

@ -3,6 +3,8 @@ version: '3.1'
services: services:
ketr.chat-production: ketr.chat-production:
volumes: 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 # - ./logs:/home/user/logs #
- ./db:/home/user/db - ./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 */ /* Allow loading of the app w/out being logged in */
app.use(basePath, index); app.use(basePath, index);
/* /chat loads the default index */ /* /chats loads the default index */
app.use(basePath + "chat", index); app.use(basePath + "chats", index);
/* Allow access to the 'users' API w/out being logged in */ /* 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 */ /* Declare the "catch all" index route last; the final route is a 404 dynamic router */
app.use(basePath, index); app.use(basePath, index);

View File

@ -1,4 +1,18 @@
# DEVELOPMENT -- use npm development server on port 3000 (entrypoint.sh) # 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 / { location / {
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@ -12,4 +26,3 @@ location / {
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
proxy_pass https://localhost:3000/ketr.chat/; 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); console.log(basePath);
basePath = "/" + basePath.replace(/^\/+/, "").replace(/\/+$/, "") + "/"; basePath = "/" + basePath.replace(/^\/+/, "").replace(/\/+$/, "") + "/";
if (basePath == "//") { if (basePath == "//") {

View File

@ -2,10 +2,13 @@ server {
root /home/user; root /home/user;
index index.html; index index.html;
access_log /var/log/nginx/access.log; listen 443 ssl;
error_log stderr;
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/ # proxy_pass has automatic redirect from v1 -> v1/
# Set the API redirect early in case endpoints have similar names # Set the API redirect early in case endpoints have similar names
@ -21,7 +24,7 @@ server {
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "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 # Set tail-pre injection for log files

File diff suppressed because it is too large Load Diff