fixed env script

+ fixed domain en port variable in svelte
This commit is contained in:
simplonco
2022-12-31 19:22:12 +01:00
parent 22ca9e9467
commit 0060f5daf7
23 changed files with 422 additions and 372 deletions

View File

@@ -1,84 +1,86 @@
#! /usr/bin/env bash #! /usr/bin/env bash
# This script is used to create a new environment for the project. # This script is used to create a new environment for the project.
#
# Create a new environment for docker ENV_FILE_DOCKER=./srcs/.env
ENV_FILE_DOCKER=./srcs/.env ENV_FILE_NESTJS=./srcs/requirements/nestjs/api_back/.env
ENV_FILE_NESTJS=./srcs/requirements/nestjs/api_back/.env # Check for existing .env
if [ -f "$ENV_FILE_DOCKER" ] && [ -f "$ENV_FILE_NESTJS" ]; then
# Create a new environment for docker
if [ -f "$ENV_FILE_DOCKER" ] && [ -f "$ENV_FILE_NESTJS" ]; then
echo "The file $ENV_FILE_DOCKER and $ENV_FILE_NESTJS already exists. Do you want to overwrite them ? (y/n)" echo "The file $ENV_FILE_DOCKER and $ENV_FILE_NESTJS already exists. Do you want to overwrite them ? (y/n)"
OVERWRITE="" OVERWRITE=""
# Ask to overwrite the .env files
while [ "$OVERWRITE" != "y" ] && [ "$OVERWRITE" != "n" ]; do while [ "$OVERWRITE" != "y" ] && [ "$OVERWRITE" != "n" ]; do
read -p "Enter your choice : " OVERWRITE read -p "Enter your choice : " OVERWRITE
done done
if [ "$OVERWRITE" = "y" ]; then if [ "$OVERWRITE" = "y" ]; then
rm "$ENV_FILE_DOCKER" && rm "$ENV_FILE_NESTJS" rm "$ENV_FILE_DOCKER" && rm "$ENV_FILE_NESTJS"
docker rmi -f postgres
else else
echo "The file $ENV_FILE_DOCKER and $ENV_FILE_NESTJS will not be overwritten. The script will exit." echo "The file $ENV_FILE_DOCKER and $ENV_FILE_NESTJS will not be overwritten. The script will exit."
exit 0 exit 0
fi fi
fi fi
echo "Creating a new environment for docker"
read -p "Enter the env configuration for nestjs : \"1\" for development OR \"2\" for production : " NODE_ENV
if [ "$NODE_ENV" = "1" ]; then # Create a new environment for docker
#
echo "Creating a new environment for docker"
NODE_ENV=""
# Ask if dev or prod environment
while [ "$NODE_ENV" != "1" ] && [ "$NODE_ENV" != "2" ]; do
read -p "Enter the env configuration for nestjs : \"1\" for development OR \"2\" for production : " NODE_ENV
done
if [ "$NODE_ENV" = "1" ]; then
echo "NODE_ENV=development" > "$ENV_FILE_DOCKER" echo "NODE_ENV=development" > "$ENV_FILE_DOCKER"
elif [ "$NODE_ENV" = "2" ]; then else
echo "NODE_ENV=production" > "$ENV_FILE_DOCKER" echo "NODE_ENV=production" > "$ENV_FILE_DOCKER"
else fi
echo "You entered a wrong value. The default value will be used (development)." # Env variables
echo "NODE_ENV=development" > "$ENV_FILE_DOCKER" read -p "Enter the name of the host like \"localhost\" : " PROJECT_HOST
fi echo "WEBSITE_HOST=$PROJECT_HOST" >> "$ENV_FILE_DOCKER"
read -p "Enter the name of the host like \"localhost\" : " PROJECT_HOST echo "WEBSITE_PORT=8080" >> "$ENV_FILE_DOCKER"
echo "WEBSITE_HOST=$PROJECT_HOST" >> "$ENV_FILE_DOCKER" echo "POSTGRES_USER=postgres" >> "$ENV_FILE_DOCKER"
echo "WEBSITE_PORT=8080" >> "$ENV_FILE_DOCKER" echo "#if change postgres pswd, do make destroy" >> "$ENV_FILE_DOCKER"
echo "POSTGRES_USER=postgres" >> "$ENV_FILE_DOCKER" POSTGRES_PASSWORD=$(openssl rand -base64 32)
POSTGRES_PASSWORD=$(openssl rand -base64 32) echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> "$ENV_FILE_DOCKER"
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> "$ENV_FILE_DOCKER" echo "POSTGRES_DB=transcendance_db" >> "$ENV_FILE_DOCKER"
echo "POSTGRES_DB=transcendance_db" >> "$ENV_FILE_DOCKER" echo "POSTGRES_HOST=postgresql" >> "$ENV_FILE_DOCKER"
echo "POSTGRES_HOST=postgresql" >> "$ENV_FILE_DOCKER" echo "POSTGRES_PORT=5432" >> "$ENV_FILE_DOCKER"
echo "POSTGRES_PORT=5432" >> "$ENV_FILE_DOCKER" echo "REDIS_HOST=redis" >> "$ENV_FILE_DOCKER"
echo "REDIS_HOST=redis" >> "$ENV_FILE_DOCKER" echo "REDIS_PORT=6379" >> "$ENV_FILE_DOCKER"
echo "REDIS_PORT=6379" >> "$ENV_FILE_DOCKER" echo "REDIS_PASSWORD=$(openssl rand -base64 32)" >> "$ENV_FILE_DOCKER"
echo "REDIS_PASSWORD=$(openssl rand -base64 32)" >> "$ENV_FILE_DOCKER"
# Create a new environment for nestjs # Create a new environment for nestjs
echo "Creating a new environment for nestjs" #
echo "Creating a new environment for nestjs"
echo "NODE_ENV=\$NODE_ENV" > "$ENV_FILE_NESTJS" echo "NODE_ENV=\$NODE_ENV" > "$ENV_FILE_NESTJS"
echo "WEBSITE_HOST=\$WEBSITE_HOST" >> "$ENV_FILE_NESTJS" echo "WEBSITE_HOST=\$WEBSITE_HOST" >> "$ENV_FILE_NESTJS"
echo "WEBSITE_PORT=\$WEBSITE_PORT" >> "$ENV_FILE_NESTJS" echo "WEBSITE_PORT=\$WEBSITE_PORT" >> "$ENV_FILE_NESTJS"
echo "POSTGRES_USER=\$POSTGRES_USER" >> "$ENV_FILE_NESTJS" echo "POSTGRES_USER=\$POSTGRES_USER" >> "$ENV_FILE_NESTJS"
echo "POSTGRES_PASSWORD=\$POSTGRES_PASSWORD" >> "$ENV_FILE_NESTJS" echo "POSTGRES_PASSWORD=\$POSTGRES_PASSWORD" >> "$ENV_FILE_NESTJS"
echo "POSTGRES_DB=\$POSTGRES_DB" >> "$ENV_FILE_NESTJS" echo "POSTGRES_DB=\$POSTGRES_DB" >> "$ENV_FILE_NESTJS"
echo "POSTGRES_HOST=\$POSTGRES_HOST" >> "$ENV_FILE_NESTJS" echo "POSTGRES_HOST=\$POSTGRES_HOST" >> "$ENV_FILE_NESTJS"
echo "POSTGRES_PORT=\$POSTGRES_PORT" >> "$ENV_FILE_NESTJS" echo "POSTGRES_PORT=\$POSTGRES_PORT" >> "$ENV_FILE_NESTJS"
# Connection to 42
echo "In the next steps, we'll need to enter the client secret and client id of the 42 api" echo "In the next steps, we'll need to enter the client secret and client id of the 42 api"
read -p "Enter the client id of the 42 api : " CLIENT_ID
read -p "Enter the client id of the 42 api : " CLIENT_ID echo "FORTYTWO_CLIENT_ID=$CLIENT_ID" >> "$ENV_FILE_NESTJS"
echo "FORTYTWO_CLIENT_ID=$CLIENT_ID" >> "$ENV_FILE_NESTJS" read -p "Enter the client secret of the 42 api : " CLIENT_SECRET
echo "FORTYTWO_CLIENT_SECRET=$CLIENT_SECRET" >> "$ENV_FILE_NESTJS"
FT_CALLBACK="http://\$WEBSITE_HOST:\$WEBSITE_PORT/api/v2/auth/redirect"
echo "FORTYTWO_CALLBACK_URL=$FT_CALLBACK" >> "$ENV_FILE_NESTJS"
# Other configs
echo "COOKIE_SECRET=$(openssl rand -base64 32)" >> "$ENV_FILE_NESTJS"
echo "PORT=3000" >> "$ENV_FILE_NESTJS"
AUTH="Transcendance"
echo "TWO_FACTOR_AUTHENTICATION_APP_NAME=$AUTH" >> "$ENV_FILE_NESTJS"
GAME_SECRET=$(openssl rand -base64 32)
echo "TICKET_FOR_PLAYING_GAME_SECRET=$GAME_SECRET" >> "$ENV_FILE_NESTJS"
read -p "Enter the client secret of the 42 api : " CLIENT_SECRET # it's finished !
echo "FORTYTWO_CLIENT_SECRET=$CLIENT_SECRET" >> "$ENV_FILE_NESTJS" #
echo "FORTYTWO_CALLBACK_URL=http://\$WEBSITE_HOST:\$WEBSITE_PORT/api/v2/auth/redirect" >> "$ENV_FILE_NESTJS" echo "The environment has been created successfully. You can now wait for the docker to build the project."
echo "COOKIE_SECRET=$(openssl rand -base64 32)" >> "$ENV_FILE_NESTJS"
echo "PORT=3000" >> "$ENV_FILE_NESTJS"
echo "REDIS_HOST=redis" >> "$ENV_FILE_DOCKER"
echo "REDIS_PORT=6379" >> "$ENV_FILE_DOCKER"
echo "REDIS_PASSWORD=$REDIS_PASSWORD" >> "$ENV_FILE_DOCKER"
echo "TWO_FACTOR_AUTHENTICATION_APP_NAME=Transcendance" >> "$ENV_FILE_NESTJS"
echo "TICKET_FOR_PLAYING_GAME_SECRET=$(openssl rand -base64 32)" >> "$ENV_FILE_NESTJS"
echo "The environment has been created successfully. You can now wait for the docker to build the project."

View File

@@ -1,4 +1,9 @@
```
FORTYTWO_CLIENT_ID=u-s4t2ud-49dc7b539bcfe1acb48b928b2b281671c99fc5bfab1faca57a536ab7e0075500
FORTYTWO_CLIENT_SECRET=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
```
https://stackoverflow.com/questions/34051747/get-environment-variable-from-docker-container https://stackoverflow.com/questions/34051747/get-environment-variable-from-docker-container
## node.js & postgresql ## node.js & postgresql

View File

@@ -2,13 +2,11 @@ NODE_ENV=development
WEBSITE_HOST=transcendance WEBSITE_HOST=transcendance
WEBSITE_PORT=8080 WEBSITE_PORT=8080
POSTGRES_USER=postgres POSTGRES_USER=postgres
POSTGRES_PASSWORD=9eEaqeSmDcCIOzartYU3RsZKuH6jqu5F3CTAOViMeFc= #if change postgres pswd, do make destroy
POSTGRES_PASSWORD=Y4a81mFbS7QDn42wEKx4i8a+o1Zex4rcgNTALS5RFoQ=
POSTGRES_DB=transcendance_db POSTGRES_DB=transcendance_db
POSTGRES_HOST=postgresql POSTGRES_HOST=postgresql
POSTGRES_PORT=5432 POSTGRES_PORT=5432
REDIS_HOST=redis REDIS_HOST=redis
REDIS_PORT=6379 REDIS_PORT=6379
REDIS_PASSWORD=UsEgAyQdMYFwf1m2n8zyQNBcD7osoVahq1YHlkq6HUY= REDIS_PASSWORD=BTNQcvEeH8h0Iry0vbbuujyKwpJP7aZ4q4i+juoDniE=
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=

View File

@@ -5,6 +5,16 @@ services:
context: ./requirements/nestjs context: ./requirements/nestjs
target: development target: development
dockerfile: Dockerfile dockerfile: Dockerfile
no_cache: true
args:
- NODE_ENV=${NODE_ENV}
- WEBSITE_HOST=${WEBSITE_HOST}
- WEBSITE_PORT=${WEBSITE_PORT}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_HOST=${POSTGRES_HOST}
- POSTGRES_PORT=${POSTGRES_PORT}
volumes: volumes:
- ./requirements/nestjs/api_back/src:/usr/app/src - ./requirements/nestjs/api_back/src:/usr/app/src
- ./requirements/nestjs/api_back/test:/usr/app/test/ - ./requirements/nestjs/api_back/test:/usr/app/test/
@@ -13,13 +23,6 @@ services:
- .env - .env
environment: environment:
NODE_ENV: "${NODE_ENV}" NODE_ENV: "${NODE_ENV}"
WEBSITE_HOST: "${WEBSITE_HOST}"
WEBSITE_PORT: "${WEBSITE_PORT}"
POSTGRES_USER: "${POSTGRES_USER}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
POSTGRES_DB: "${POSTGRES_DB}"
POSTGRES_HOST: "${POSTGRES_HOST}"
POSTGRES_PORT: "${POSTGRES_PORT}"
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- postgresql - postgresql

View File

@@ -26,5 +26,5 @@ RUN sed -i "s/\$NODE_ENV/${NODE_ENV}/g" ./.env && \
RUN npm install RUN npm install
RUN npm ci RUN npm ci
CMD [ "npm", "run", "start:dev" ] CMD [ "npm", "run", "start:dev" ]

View File

@@ -2,14 +2,14 @@ NODE_ENV=$NODE_ENV
WEBSITE_HOST=$WEBSITE_HOST WEBSITE_HOST=$WEBSITE_HOST
WEBSITE_PORT=$WEBSITE_PORT WEBSITE_PORT=$WEBSITE_PORT
POSTGRES_USER=$POSTGRES_USER POSTGRES_USER=$POSTGRES_USER
POSTGRES_PASSWORD= POSTGRES_PASSWORD=$POSTGRES_PASSWORD
POSTGRES_DB=$POSTGRES_DB POSTGRES_DB=$POSTGRES_DB
POSTGRES_HOST=$POSTGRES_HOST POSTGRES_HOST=$POSTGRES_HOST
POSTGRES_PORT=$POSTGRES_PORT POSTGRES_PORT=$POSTGRES_PORT
FORTYTWO_CLIENT_ID=u-s4t2ud-49dc7b539bcfe1acb48b928b2b281671c99fc5bfab1faca57a536ab7e0075500 FORTYTWO_CLIENT_ID=u-s4t2ud-49dc7b539bcfe1acb48b928b2b281671c99fc5bfab1faca57a536ab7e0075500
FORTYTWO_CLIENT_SECRET=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 FORTYTWO_CLIENT_SECRET=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
FORTYTWO_CALLBACK_URL=http://$WEBSITE_HOST:$WEBSITE_PORT/api/v2/auth/redirect FORTYTWO_CALLBACK_URL=http://$WEBSITE_HOST:$WEBSITE_PORT/api/v2/auth/redirect
COOKIE_SECRET=612IIHKJW6uUFSXTJZWh7UpnhykPlsAi1Adm6hOSVmc= COOKIE_SECRET=FgqjKDff1NBior+t1R3xPgr4Qop2mzE6BOaDb2i1azI=
PORT=3000 PORT=3000
TWO_FACTOR_AUTHENTICATION_APP_NAME=Transcendance TWO_FACTOR_AUTHENTICATION_APP_NAME=Transcendance
TICKET_FOR_PLAYING_GAME_SECRET=0Z8t/fr9WN0rVMeeieO2DoubHFE+Zw0/9q8Af4s9KBg= TICKET_FOR_PLAYING_GAME_SECRET=PhszotanbBviW3nHNklQ5IizKU3fmv3KJhrJqRT8Zag=

View File

@@ -17,6 +17,8 @@ export class ChatGateway
@WebSocketServer() @WebSocketServer()
server; server;
// how to guard the handleConnection ?
// https://github.com/nestjs/nest/issues/882
handleConnection(client) { handleConnection(client) {
console.log('---- Client connected :', client.id); console.log('---- Client connected :', client.id);
} }

View File

@@ -1,21 +1,21 @@
header.svelte-7t4byu.svelte-7t4byu{overflow-y:hidden}.grid-container.svelte-7t4byu.svelte-7t4byu{position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;white-space:nowrap;margin-bottom:0px;overflow:hidden;padding:20px 40px;margin:0px;display:grid;grid-template-columns:repeat(12, 1fr);grid-template-rows:1fr 1fr 1fr 1fr 1fr;align-items:center}header.svelte-7t4byu h1.svelte-7t4byu{grid-column:1 / 7;grid-row:1;padding:20px;border:1px solid bisque}header.svelte-7t4byu nav.svelte-7t4byu{grid-column:7 / 13;grid-row:1;justify-self:end;padding:20px;border:1px solid bisque}header.svelte-7t4byu h2.svelte-7t4byu{grid-row:3;grid-column:5 / span 4;justify-self:center;border:1px solid black;z-index:3}header.svelte-7t4byu h2 div.svelte-7t4byu{font-size:2em}nav.svelte-7t4byu div.svelte-7t4byu{display:inline;color:bisque;font-weight:bold}nav.svelte-7t4byu>div.svelte-7t4byu{padding-left:1em}nav.svelte-7t4byu div.svelte-7t4byu:hover{text-decoration:underline;cursor:pointer}main.svelte-1cznfcz.svelte-1cznfcz{text-align:center;padding-top:40px;padding-bottom:40px}form.svelte-1cznfcz.svelte-1cznfcz{padding-top:15px}form.svelte-1cznfcz input.svelte-1cznfcz{max-width:330px}.error.svelte-1cznfcz.svelte-1cznfcz{font-weight:bold;font-size:0.8em;color:red}div.wrapper.svelte-1q8uute{display:flexbox;align-items:center}div.wrapper.svelte-1q8uute{display:flexbox;align-items:center}@font-face{font-family:"Bit5x3";src:url("/fonts/Bit5x3.woff2") format("woff2"), div.wrapper.svelte-1q8uute{display:flexbox;align-items:center}div.wrapper.svelte-1q8uute{display:flexbox;align-items:center}header.svelte-7t4byu.svelte-7t4byu{overflow-y:hidden}.grid-container.svelte-7t4byu.svelte-7t4byu{position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;white-space:nowrap;margin-bottom:0px;overflow:hidden;padding:20px 40px;margin:0px;display:grid;grid-template-columns:repeat(12, 1fr);grid-template-rows:1fr 1fr 1fr 1fr 1fr;align-items:center}header.svelte-7t4byu h1.svelte-7t4byu{grid-column:1 / 7;grid-row:1;padding:20px;border:1px solid bisque}header.svelte-7t4byu nav.svelte-7t4byu{grid-column:7 / 13;grid-row:1;justify-self:end;padding:20px;border:1px solid bisque}header.svelte-7t4byu h2.svelte-7t4byu{grid-row:3;grid-column:5 / span 4;justify-self:center;border:1px solid black;z-index:3}header.svelte-7t4byu h2 div.svelte-7t4byu{font-size:2em}nav.svelte-7t4byu div.svelte-7t4byu{display:inline;color:bisque;font-weight:bold}nav.svelte-7t4byu>div.svelte-7t4byu{padding-left:1em}nav.svelte-7t4byu div.svelte-7t4byu:hover{text-decoration:underline;cursor:pointer}main.svelte-1cznfcz.svelte-1cznfcz{text-align:center;padding-top:40px;padding-bottom:40px}form.svelte-1cznfcz.svelte-1cznfcz{padding-top:15px}form.svelte-1cznfcz input.svelte-1cznfcz{max-width:330px}.error.svelte-1cznfcz.svelte-1cznfcz{font-weight:bold;font-size:0.8em;color:red}@font-face{font-family:"Bit5x3";src:url("/fonts/Bit5x3.woff2") format("woff2"),
local("Bit5x3"), local("Bit5x3"),
url("/fonts/Bit5x3.woff") format("woff");font-weight:normal;font-style:normal;font-display:swap}#game_page.svelte-y455cj.svelte-y455cj{margin:0;background-color:#222425;position:relative;width:100%;height:100%}#canvas_container.svelte-y455cj.svelte-y455cj{margin-top:20px;text-align:center}#users_name.svelte-y455cj.svelte-y455cj{text-align:center;font-family:"Bit5x3";color:rgb(245, 245, 245);font-size:x-large}#div_game.svelte-y455cj.svelte-y455cj{margin-top:20px;text-align:center;font-family:"Bit5x3";color:rgb(245, 245, 245);font-size:x-large}#error_notification.svelte-y455cj.svelte-y455cj{text-align:center;display:block;font-family:"Bit5x3";color:rgb(143, 19, 19);font-size:x-large}#div_game.svelte-y455cj fieldset.svelte-y455cj{max-width:50vw;width:auto;margin:0 auto}#div_game.svelte-y455cj fieldset div.svelte-y455cj{padding:10px}#pong_button.svelte-y455cj.svelte-y455cj{font-family:"Bit5x3";color:rgb(245, 245, 245);background-color:#333333;font-size:x-large;padding:10px}canvas.svelte-y455cj.svelte-y455cj{background-color:#333333;max-width:75vw;width:80%}canvas.svelte-1bstsd0{width:100%;height:100%;background-color:#666}@font-face{font-family:'Bondi';src:url('/fonts/Bondi.ttf.woff') format('woff'), url("/fonts/Bit5x3.woff") format("woff");font-weight:normal;font-style:normal;font-display:swap}#game_page.svelte-y455cj.svelte-y455cj{margin:0;background-color:#222425;position:relative;width:100%;height:100%}#canvas_container.svelte-y455cj.svelte-y455cj{margin-top:20px;text-align:center}#users_name.svelte-y455cj.svelte-y455cj{text-align:center;font-family:"Bit5x3";color:rgb(245, 245, 245);font-size:x-large}#div_game.svelte-y455cj.svelte-y455cj{margin-top:20px;text-align:center;font-family:"Bit5x3";color:rgb(245, 245, 245);font-size:x-large}#error_notification.svelte-y455cj.svelte-y455cj{text-align:center;display:block;font-family:"Bit5x3";color:rgb(143, 19, 19);font-size:x-large}#div_game.svelte-y455cj fieldset.svelte-y455cj{max-width:50vw;width:auto;margin:0 auto}#div_game.svelte-y455cj fieldset div.svelte-y455cj{padding:10px}#pong_button.svelte-y455cj.svelte-y455cj{font-family:"Bit5x3";color:rgb(245, 245, 245);background-color:#333333;font-size:x-large;padding:10px}canvas.svelte-y455cj.svelte-y455cj{background-color:#333333;max-width:75vw;width:80%}@font-face{font-family:'Bondi';src:url('/fonts/Bondi.ttf.woff') format('woff'),
url('/fonts/Bondi.ttf.svg#Bondi') format('svg'), url('/fonts/Bondi.ttf.svg#Bondi') format('svg'),
url('/fonts/Bondi.ttf.eot'), url('/fonts/Bondi.ttf.eot'),
url('/fonts/Bondi.ttf.eot?#iefix') format('embedded-opentype');font-weight:normal;font-style:normal}header.svelte-1aisfio.svelte-1aisfio{background:#618174;margin:0}header.svelte-1aisfio.svelte-1aisfio{position:sticky;display:grid;grid-template-columns:1fr 1fr 1fr}h1.svelte-1aisfio.svelte-1aisfio{font-family:'Bondi'}h1.svelte-1aisfio.svelte-1aisfio{margin:0;text-align:left;display:flex;justify-self:center;align-self:center}img.svelte-1aisfio.svelte-1aisfio{cursor:pointer;max-width:40px;padding:7px 20px;justify-self:left}nav.svelte-1aisfio.svelte-1aisfio{display:flex;justify-content:right}nav.svelte-1aisfio button.svelte-1aisfio{margin:7px 20px;border-radius:4px}div.outer.svelte-1tyjf3q{max-width:960px;margin:40px auto}:root{--purple:rgb(123, 31, 162);--violet:rgb(103, 58, 183);--pink:rgb(244, 143, 177)}@keyframes svelte-1tyjf3q-background-pan{from{background-position:0% center}to{background-position:-200% center}}@keyframes svelte-1tyjf3q-scale{from,to{transform:scale(0)}50%{transform:scale(1)}}@keyframes svelte-1tyjf3q-rotate{from{transform:rotate(0deg)}to{transform:rotate(180deg)}}main.svelte-qtbld7{text-align:center}div.cards.svelte-qtbld7{display:grid;grid-template-columns:1fr 1fr;grid-gap:20px}img.svelte-qtbld7{width:60px}form.svelte-qtbld7{text-align:center}.form-field.svelte-qtbld7{padding:10px}.label.svelte-qtbld7{font-weight:bold}.inline-check.svelte-qtbld7{display:inline}.error.svelte-qtbld7{font-size:0.8em;font-weight:bold;color:red}.success.svelte-qtbld7{font-size:0.8em;font-weight:bold;color:green}div.top-grid.svelte-55f7si{display:grid;grid-template-columns:repeat(12, 1fr);height:85vh}div.all-users-sidebar.svelte-55f7si{grid-column:1 / span 2;background:white}div.a-user.svelte-55f7si{display:inline-block}div.status.svelte-55f7si{font-size:0.6em;font-weight:bold}div[class^="a-user"].svelte-55f7si:hover{text-decoration:underline;font-weight:bold;cursor:pointer}div.main-display.svelte-55f7si{grid-column:3 / span 10}.error.svelte-55f7si{font-size:0.8em;font-weight:bold;color:red}div.outer.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{max-width:960px;margin:40px auto}main.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{max-width:960px;margin:40px auto;text-align:center}.avatar.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{max-width:150px}section.main-stats.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{max-width:600px;margin:40px auto;text-align:center;display:grid;grid-template-columns:repeat(3, 1fr);grid-template-rows:repeat(3, 1fr)}section.main-stats.svelte-16aefqu h4.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{grid-column:1 / span 3}div.username.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{font-size:1.5em;font-weight:bold;padding-bottom:5px}div.rank.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{font-size:1.2em;font-weight:bold}:root{--purple:rgb(123, 31, 162);--violet:rgb(103, 58, 183);--pink:rgb(244, 143, 177)}@keyframes svelte-16aefqu-background-pan{from{background-position:0% center}to{background-position:-200% center}}@keyframes svelte-16aefqu-scale{from,to{transform:scale(0)}50%{transform:scale(1)}}@keyframes svelte-16aefqu-rotate{from{transform:rotate(0deg)}to{transform:rotate(180deg)}}div.svelte-16aefqu>.glitter.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{display:inline-block;position:relative}div.svelte-16aefqu>.glitter.svelte-16aefqu>.glitter-star.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{--size:clamp(20px, 1.5vw, 30px);animation:svelte-16aefqu-scale 700ms ease forwards;display:block;height:var(--size);left:var(--star-left);position:absolute;top:var(--star-top);width:var(--size)}div.svelte-16aefqu>.glitter.svelte-16aefqu>.glitter-star.svelte-16aefqu>svg.svelte-16aefqu.svelte-16aefqu{animation:svelte-16aefqu-rotate 1000ms linear infinite;display:block;opacity:0.7}div.svelte-16aefqu>.glitter.svelte-16aefqu>.glitter-star.svelte-16aefqu>svg.svelte-16aefqu>path.svelte-16aefqu{fill:var(--violet)}div.svelte-16aefqu>.glitter.svelte-16aefqu>.glitter-text.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{animation:svelte-16aefqu-background-pan 3s linear infinite;background:linear-gradient( url('/fonts/Bondi.ttf.eot?#iefix') format('embedded-opentype');font-weight:normal;font-style:normal}header.svelte-1aisfio.svelte-1aisfio{background:#618174;margin:0}header.svelte-1aisfio.svelte-1aisfio{position:sticky;display:grid;grid-template-columns:1fr 1fr 1fr}h1.svelte-1aisfio.svelte-1aisfio{font-family:'Bondi'}h1.svelte-1aisfio.svelte-1aisfio{margin:0;text-align:left;display:flex;justify-self:center;align-self:center}img.svelte-1aisfio.svelte-1aisfio{cursor:pointer;max-width:40px;padding:7px 20px;justify-self:left}nav.svelte-1aisfio.svelte-1aisfio{display:flex;justify-content:right}nav.svelte-1aisfio button.svelte-1aisfio{margin:7px 20px;border-radius:4px}canvas.svelte-1bstsd0{width:100%;height:100%;background-color:#666}div.outer.svelte-1tyjf3q{max-width:960px;margin:40px auto}:root{--purple:rgb(123, 31, 162);--violet:rgb(103, 58, 183);--pink:rgb(244, 143, 177)}@keyframes svelte-1tyjf3q-background-pan{from{background-position:0% center}to{background-position:-200% center}}@keyframes svelte-1tyjf3q-scale{from,to{transform:scale(0)}50%{transform:scale(1)}}@keyframes svelte-1tyjf3q-rotate{from{transform:rotate(0deg)}to{transform:rotate(180deg)}}main.svelte-qtbld7{text-align:center}div.cards.svelte-qtbld7{display:grid;grid-template-columns:1fr 1fr;grid-gap:20px}img.svelte-qtbld7{width:60px}form.svelte-qtbld7{text-align:center}.form-field.svelte-qtbld7{padding:10px}.label.svelte-qtbld7{font-weight:bold}.inline-check.svelte-qtbld7{display:inline}.error.svelte-qtbld7{font-size:0.8em;font-weight:bold;color:red}.success.svelte-qtbld7{font-size:0.8em;font-weight:bold;color:green}div.top-grid.svelte-55f7si{display:grid;grid-template-columns:repeat(12, 1fr);height:85vh}div.all-users-sidebar.svelte-55f7si{grid-column:1 / span 2;background:white}div.a-user.svelte-55f7si{display:inline-block}div.status.svelte-55f7si{font-size:0.6em;font-weight:bold}div[class^="a-user"].svelte-55f7si:hover{text-decoration:underline;font-weight:bold;cursor:pointer}div.main-display.svelte-55f7si{grid-column:3 / span 10}.error.svelte-55f7si{font-size:0.8em;font-weight:bold;color:red}.card.svelte-8smyff{background:white;padding:20px;border-radius:6px;box-shadow:0px 2px 4px rgba(0,0,0,0.1)}button.svelte-1u0z9cq{border:0;cursor:pointer;border-radius:6px;padding:8px 12px;font-weight:bold;box-shadow:1px 2px 3px rgba(0,0,0,0.2)}.primary.svelte-1u0z9cq{background:#d91b42;color:white}.secondary.svelte-1u0z9cq{background:#45c496;color:white}.flat.svelte-1u0z9cq{box-shadow:none}.primary.inverse.svelte-1u0z9cq{color:#d91b42;background:white;border:2px solid #d91b42}.secondary.inverse.svelte-1u0z9cq{color:#45c496;background:white;border:2px solid #45c496}div.outer.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{max-width:960px;margin:40px auto}main.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{max-width:960px;margin:40px auto;text-align:center}.avatar.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{max-width:150px}section.main-stats.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{max-width:600px;margin:40px auto;text-align:center;display:grid;grid-template-columns:repeat(3, 1fr);grid-template-rows:repeat(3, 1fr)}section.main-stats.svelte-16aefqu h4.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{grid-column:1 / span 3}div.username.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{font-size:1.5em;font-weight:bold;padding-bottom:5px}div.rank.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{font-size:1.2em;font-weight:bold}:root{--purple:rgb(123, 31, 162);--violet:rgb(103, 58, 183);--pink:rgb(244, 143, 177)}@keyframes svelte-16aefqu-background-pan{from{background-position:0% center}to{background-position:-200% center}}@keyframes svelte-16aefqu-scale{from,to{transform:scale(0)}50%{transform:scale(1)}}@keyframes svelte-16aefqu-rotate{from{transform:rotate(0deg)}to{transform:rotate(180deg)}}div.svelte-16aefqu>.glitter.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{display:inline-block;position:relative}div.svelte-16aefqu>.glitter.svelte-16aefqu>.glitter-star.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{--size:clamp(20px, 1.5vw, 30px);animation:svelte-16aefqu-scale 700ms ease forwards;display:block;height:var(--size);left:var(--star-left);position:absolute;top:var(--star-top);width:var(--size)}div.svelte-16aefqu>.glitter.svelte-16aefqu>.glitter-star.svelte-16aefqu>svg.svelte-16aefqu.svelte-16aefqu{animation:svelte-16aefqu-rotate 1000ms linear infinite;display:block;opacity:0.7}div.svelte-16aefqu>.glitter.svelte-16aefqu>.glitter-star.svelte-16aefqu>svg.svelte-16aefqu>path.svelte-16aefqu{fill:var(--violet)}div.svelte-16aefqu>.glitter.svelte-16aefqu>.glitter-text.svelte-16aefqu.svelte-16aefqu.svelte-16aefqu{animation:svelte-16aefqu-background-pan 3s linear infinite;background:linear-gradient(
to right, to right,
var(--purple), var(--purple),
var(--violet), var(--violet),
var(--pink), var(--pink),
var(--purple) var(--purple)
);background-size:200%;-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;color:transparent;white-space:nowrap}.card.svelte-8smyff{background:white;padding:20px;border-radius:6px;box-shadow:0px 2px 4px rgba(0,0,0,0.1)}button.svelte-1u0z9cq{border:0;cursor:pointer;border-radius:6px;padding:8px 12px;font-weight:bold;box-shadow:1px 2px 3px rgba(0,0,0,0.2)}.primary.svelte-1u0z9cq{background:#d91b42;color:white}.secondary.svelte-1u0z9cq{background:#45c496;color:white}.flat.svelte-1u0z9cq{box-shadow:none}.primary.inverse.svelte-1u0z9cq{color:#d91b42;background:white;border:2px solid #d91b42}.secondary.inverse.svelte-1u0z9cq{color:#45c496;background:white;border:2px solid #45c496}.chat_box.svelte-auy6qm{display:flex;position:fixed;bottom:20px;right:20px;padding:0px;width:auto;height:auto;border:1px solid black}.chat_box.svelte-auy6qm *{-ms-overflow-style:none;scrollbar-width:none}.chat_box.svelte-auy6qm *::-webkit-scrollbar{display:none}.chat_box.svelte-auy6qm .grid_box{display:grid;margin:5px;gap:5px;width:300px;height:400px}.chat_box.svelte-auy6qm .grid_box *{display:flex;flex-direction:column;position:relative;box-sizing:border-box}.chat_box.svelte-auy6qm .grid_box p{padding:10px;font-size:15px}.chat_box.svelte-auy6qm .panel{overflow-y:scroll}.chat_box.svelte-auy6qm .panel > *{margin-top:10px;margin-bottom:10px}.chat_box.svelte-auy6qm .__show_if_only_child{display:none}.chat_box.svelte-auy6qm .__show_if_only_child:only-child{display:flex;color:rgb(100, 100, 100)}.chat_box.svelte-auy6qm .__center{margin-left:auto;margin-right:auto}.chat_box.svelte-auy6qm .__border_top{border-top:1px solid black}.chat_box.svelte-auy6qm .__check_change_next:checked ~ .__to_show{display:flex}.chat_box.svelte-auy6qm .__check_change_next:checked ~ .__to_block,.chat_box.svelte-auy6qm .__check_change_next:checked ~ .__to_block *{pointer-events:none;color:rgb(100, 100, 100)}.chat_box.svelte-auy6qm .__to_show{display:none}.grid_box.svelte-fc4a40 .chat{grid-area:chat}.grid_box.svelte-fc4a40{gap:0px;grid:' chat ' auto );background-size:200%;-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;color:transparent;white-space:nowrap}.grid_box.svelte-rmdfjs .back {grid-area:back}.grid_box.svelte-rmdfjs .room_name {grid-area:room_name}.grid_box.svelte-rmdfjs .close {grid-area:close}.grid_box.svelte-rmdfjs .panel_msg {grid-area:panel_msg}.grid_box.svelte-rmdfjs .send {grid-area:send}.grid_box.svelte-rmdfjs .panel_write{grid-area:panel_write}.grid_box.svelte-rmdfjs.svelte-rmdfjs{grid:' back room_name room_name close ' auto
/ auto }.chat_box.close .grid_box.svelte-fc4a40{margin:0px;width:auto;height:auto}.grid_box.svelte-1jygwt2 .settings {grid-area:settings}.grid_box.svelte-1jygwt2 .close {grid-area:close}.grid_box.svelte-1jygwt2 .new {grid-area:new}.grid_box.svelte-1jygwt2 .panel_home{grid-area:panel_home}.grid_box.svelte-1jygwt2.svelte-1jygwt2{grid:' settings new close ' auto
' panel_home panel_home panel_home ' 1fr
/ auto 1fr auto }.panel_home.svelte-1jygwt2 p.title.svelte-1jygwt2{margin:10px auto 0px auto}.grid_box.svelte-rmdfjs .back {grid-area:back}.grid_box.svelte-rmdfjs .room_name {grid-area:room_name}.grid_box.svelte-rmdfjs .close {grid-area:close}.grid_box.svelte-rmdfjs .panel_msg {grid-area:panel_msg}.grid_box.svelte-rmdfjs .send {grid-area:send}.grid_box.svelte-rmdfjs .panel_write{grid-area:panel_write}.grid_box.svelte-rmdfjs.svelte-rmdfjs{grid:' back room_name room_name close ' auto
' panel_msg panel_msg panel_msg panel_msg ' 1fr ' panel_msg panel_msg panel_msg panel_msg ' 1fr
' panel_write panel_write send send ' auto ' panel_write panel_write send send ' auto
/ auto 1fr auto auto }.panel_write.svelte-rmdfjs.svelte-rmdfjs{border:none;overflow:visible}.text_area.svelte-rmdfjs.svelte-rmdfjs{display:block;position:absolute;bottom:0px;left:0px;width:100%;height:100%;overflow-x:hidden;overflow-y:scroll;background-color:white;border:1px solid black}.text_area.svelte-rmdfjs.svelte-rmdfjs:focus{height:auto;min-height:100%;max-height:300px}.panel_write.svelte-rmdfjs .text_area.svelte-rmdfjs *{display:block ruby}.panel_msg.svelte-rmdfjs.svelte-rmdfjs{flex-direction:column-reverse;border:1px solid black}.msg_thread.svelte-rmdfjs.svelte-rmdfjs{width:100%;padding:0px 5px}.grid_box.svelte-1b4c0qx .back {grid-area:back}.grid_box.svelte-1b4c0qx .new {grid-area:new}.grid_box.svelte-1b4c0qx .close {grid-area:close}.grid_box.svelte-1b4c0qx .panel_new{grid-area:panel_new}.grid_box.svelte-1b4c0qx{grid:' back new close ' auto / auto 1fr auto auto }.panel_write.svelte-rmdfjs.svelte-rmdfjs{border:none;overflow:visible}.text_area.svelte-rmdfjs.svelte-rmdfjs{display:block;position:absolute;bottom:0px;left:0px;width:100%;height:100%;overflow-x:hidden;overflow-y:scroll;background-color:white;border:1px solid black}.text_area.svelte-rmdfjs.svelte-rmdfjs:focus{height:auto;min-height:100%;max-height:300px}.panel_write.svelte-rmdfjs .text_area.svelte-rmdfjs *{display:block ruby}.panel_msg.svelte-rmdfjs.svelte-rmdfjs{flex-direction:column-reverse;border:1px solid black}.msg_thread.svelte-rmdfjs.svelte-rmdfjs{width:100%;padding:0px 5px}.grid_box.svelte-1jygwt2 .settings {grid-area:settings}.grid_box.svelte-1jygwt2 .close {grid-area:close}.grid_box.svelte-1jygwt2 .new {grid-area:new}.grid_box.svelte-1jygwt2 .panel_home{grid-area:panel_home}.grid_box.svelte-1jygwt2.svelte-1jygwt2{grid:' settings new close ' auto
' panel_home panel_home panel_home ' 1fr
/ auto 1fr auto }.panel_home.svelte-1jygwt2 p.title.svelte-1jygwt2{margin:10px auto 0px auto}.chat_box.svelte-auy6qm{display:flex;position:fixed;bottom:20px;right:20px;padding:0px;width:auto;height:auto;border:1px solid black}.chat_box.svelte-auy6qm *{-ms-overflow-style:none;scrollbar-width:none}.chat_box.svelte-auy6qm *::-webkit-scrollbar{display:none}.chat_box.svelte-auy6qm .grid_box{display:grid;margin:5px;gap:5px;width:300px;height:400px}.chat_box.svelte-auy6qm .grid_box *{display:flex;flex-direction:column;position:relative;box-sizing:border-box}.chat_box.svelte-auy6qm .grid_box p{padding:10px;font-size:15px}.chat_box.svelte-auy6qm .panel{overflow-y:scroll}.chat_box.svelte-auy6qm .panel > *{margin-top:10px;margin-bottom:10px}.chat_box.svelte-auy6qm .__show_if_only_child{display:none}.chat_box.svelte-auy6qm .__show_if_only_child:only-child{display:flex;color:rgb(100, 100, 100)}.chat_box.svelte-auy6qm .__center{margin-left:auto;margin-right:auto}.chat_box.svelte-auy6qm .__border_top{border-top:1px solid black}.chat_box.svelte-auy6qm .__check_change_next:checked ~ .__to_show{display:flex}.chat_box.svelte-auy6qm .__check_change_next:checked ~ .__to_block,.chat_box.svelte-auy6qm .__check_change_next:checked ~ .__to_block *{pointer-events:none;color:rgb(100, 100, 100)}.chat_box.svelte-auy6qm .__to_show{display:none}.grid_box.svelte-fc4a40 .chat{grid-area:chat}.grid_box.svelte-fc4a40{gap:0px;grid:' chat ' auto
/ auto }.chat_box.close .grid_box.svelte-fc4a40{margin:0px;width:auto;height:auto}.grid_box.svelte-1b4c0qx .back {grid-area:back}.grid_box.svelte-1b4c0qx .new {grid-area:new}.grid_box.svelte-1b4c0qx .close {grid-area:close}.grid_box.svelte-1b4c0qx .panel_new{grid-area:panel_new}.grid_box.svelte-1b4c0qx{grid:' back new close ' auto
' panel_new panel_new panel_new ' 1fr ' panel_new panel_new panel_new ' 1fr
/ auto 1fr auto }.grid_box.svelte-1lfmc2m .back {grid-area:back}.grid_box.svelte-1lfmc2m .settings {grid-area:settings}.grid_box.svelte-1lfmc2m .close {grid-area:close}.grid_box.svelte-1lfmc2m .panel_settings{grid-area:panel_settings}.grid_box.svelte-1lfmc2m{grid:' back settings close ' auto / auto 1fr auto }.grid_box.svelte-1lfmc2m .back {grid-area:back}.grid_box.svelte-1lfmc2m .settings {grid-area:settings}.grid_box.svelte-1lfmc2m .close {grid-area:close}.grid_box.svelte-1lfmc2m .panel_settings{grid-area:panel_settings}.grid_box.svelte-1lfmc2m{grid:' back settings close ' auto
' panel_settings panel_settings panel_settings ' 1fr ' panel_settings panel_settings panel_settings ' 1fr

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,5 @@
<script context="module"> <script context="module">
export const Domain = "transcendance"; export const Domain = "transcendance";
export const Port = 8080; export const Port = "8080";
export const PortIo = "8080";
</script> </script>

View File

@@ -3,13 +3,13 @@
import { push } from "svelte-spa-router"; import { push } from "svelte-spa-router";
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { get } from "svelte/store"; import { get } from "svelte/store";
import { Domain } from "../Constantes.svelte"; import { Domain, Port } from "../Constantes.svelte";
let user; let user;
onMount(async () => { onMount(async () => {
user = await fetch('http://{Domain}:8080/api/v2/user') user = await fetch(`http://${Domain}:${Port}/api/v2/user`)
.then((resp) => resp.json()) .then((resp) => resp.json())
// i mean i could do a failed to load user or some shit, maybe with a .catch or something? but atm why bother // i mean i could do a failed to load user or some shit, maybe with a .catch or something? but atm why bother
@@ -33,14 +33,14 @@
}); });
const login = async() => { const login = async() => {
window.location.href = 'http://{Domain}:8080/api/v2/auth'; window.location.href = `http://${Domain}:${Port}/api/v2/auth`;
console.log('you are now logged in'); console.log('you are now logged in');
} }
// i could prolly put this in it's own compoent, i seem to use it in several places... or maybe just some JS? like no need for html // i could prolly put this in it's own compoent, i seem to use it in several places... or maybe just some JS? like no need for html
// we could .then( () => replace('/') ) need the func so TS compatible... // we could .then( () => replace('/') ) need the func so TS compatible...
const logout = async() => { const logout = async() => {
await fetch('http://{Domain}:8080/api/v2/auth/logout', { await fetch(`http://${Domain}:${Port}/api/v2/auth/logout`, {
method: 'POST', method: 'POST',
}); });
user = undefined; user = undefined;

View File

@@ -4,7 +4,7 @@
import { Domain, Port } from "../Constantes.svelte"; import { Domain, Port } from "../Constantes.svelte";
// onMount( async() => { // onMount( async() => {
// await fetch("http://{Domain}:{Port}/api/v2/auth/2fa/generate", // await fetch(`http://${Domain}:${Port}/api/v2/auth/2fa/generate`,
// { // {
// method: 'POST', // method: 'POST',
// }) // })
@@ -20,7 +20,7 @@
let qrCode = ""; let qrCode = "";
let wrongCode = ""; let wrongCode = "";
const fetchQrCodeImg = (async() => { const fetchQrCodeImg = (async() => {
await fetch("http://{Domain}:{Port}/api/v2/auth/2fa/generate", await fetch(`http://${Domain}:${Port}/api/v2/auth/2fa/generate`,
{ {
method: 'POST', method: 'POST',
}) })
@@ -32,7 +32,7 @@
})() })()
const submitCode = async() => { const submitCode = async() => {
const response = await fetch("http://{Domain}:{Port}/api/v2/auth/2fa/check", const response = await fetch(`http://${Domain}:${Port}/api/v2/auth/2fa/check`,
{ {
method : 'POST', method : 'POST',
headers : { headers : {

View File

@@ -37,9 +37,9 @@
let idOfIntevalCheckTerminationOfTheMatch; let idOfIntevalCheckTerminationOfTheMatch;
onMount( async() => { onMount( async() => {
user = await fetch('http://{Domain}:{Port}/api/v2/user') user = await fetch(`http://${Domain}:${Port}/api/v2/user`)
.then( x => x.json() ); .then( x => x.json() );
allUsers = await fetch('http://{Domain}:{Port}/api/v2/user/all') allUsers = await fetch(`http://${Domain}:${Port}/api/v2/user/all`)
.then( x => x.json() ); .then( x => x.json() );
options.playerOneUsername = user.username; options.playerOneUsername = user.username;
}) })
@@ -69,7 +69,7 @@
idOfIntevalCheckTerminationOfTheMatch = setInterval(matchTermitation, 1000); idOfIntevalCheckTerminationOfTheMatch = setInterval(matchTermitation, 1000);
const matchOptions = pong.computeMatchOptions(options); const matchOptions = pong.computeMatchOptions(options);
const responseWhenGrantToken = fetch("http://{Domain}:{Port}/api/v2/game/ticket", { const responseWhenGrantToken = fetch(`http://${Domain}:${Port}/api/v2/game/ticket`, {
method : "POST", method : "POST",
headers : {'Content-Type': 'application/json'}, headers : {'Content-Type': 'application/json'},
body : JSON.stringify({ body : JSON.stringify({
@@ -174,13 +174,13 @@
const showInvitation = async() => { const showInvitation = async() => {
showGameOption = false; showGameOption = false;
showInvitations = true; showInvitations = true;
invitations = await fetch("http://{Domain}:{Port}/api/v2/game/invitations") invitations = await fetch(`http://${Domain}:${Port}/api/v2/game/invitations`)
.then(x => x.json()) .then(x => x.json())
invitations.length !== 0 ? isThereAnyInvitation = true : isThereAnyInvitation = false invitations.length !== 0 ? isThereAnyInvitation = true : isThereAnyInvitation = false
} }
const rejectInvitation = async(invitation) => { const rejectInvitation = async(invitation) => {
await fetch("http://{Domain}:{Port}/api/v2/game/decline",{ await fetch(`http://${Domain}:${Port}/api/v2/game/decline`, {
method: "POST", method: "POST",
headers: { 'Content-Type': 'application/json'}, headers: { 'Content-Type': 'application/json'},
body: JSON.stringify({ body: JSON.stringify({
@@ -193,7 +193,7 @@
} }
const acceptInvitation = async(invitation : any) => { const acceptInvitation = async(invitation : any) => {
const res = await fetch("http://{Domain}:{Port}/api/v2/game/accept",{ const res = await fetch(`http://${Domain}:${Port}/api/v2/game/accept`, {
method: "POST", method: "POST",
headers: { 'Content-Type': 'application/json'}, headers: { 'Content-Type': 'application/json'},
body: JSON.stringify({ body: JSON.stringify({

View File

@@ -21,9 +21,9 @@
let hiddenGame = true; let hiddenGame = true;
onMount( async() => { onMount( async() => {
user = await fetch('http://{Domain}:{Port}/api/v2/user') user = await fetch(`http://${Domain}:${Port}/api/v2/user`)
.then( x => x.json() ); .then( x => x.json() );
allUsers = await fetch('http://{Domain}:{Port}/api/v2/user/all') allUsers = await fetch(`http://${Domain}:${Port}/api/v2/user/all`)
.then( x => x.json() ); .then( x => x.json() );
}) })

View File

@@ -9,9 +9,9 @@
let allUsers = []; let allUsers = [];
let idInterval; let idInterval;
onMount( async() => { onMount( async() => {
currentUser = await fetch('http://{Domain}:{Port}/api/v2/user') currentUser = await fetch(`http://${Domain}:${Port}/api/v2/user`)
.then( x => x.json() ); .then( x => x.json() );
allUsers = await fetch('http://{Domain}:{Port}/api/v2/game/ranking') allUsers = await fetch(`http://${Domain}:${Port}/api/v2/game/ranking`)
.then( x => x.json() ); .then( x => x.json() );
idInterval = setInterval(fetchScores, 10000); idInterval = setInterval(fetchScores, 10000);
}) })
@@ -21,7 +21,7 @@
}) })
function fetchScores() { function fetchScores() {
fetch('http://{Domain}:{Port}/api/v2/game/ranking') fetch(`http://${Domain}:${Port}/api/v2/game/ranking`)
.then( x => x.json() ) .then( x => x.json() )
.then( x => allUsers = x ); .then( x => allUsers = x );
} }

View File

@@ -10,7 +10,7 @@
onMount( async() => { onMount( async() => {
// console.log('mounting profile display') // console.log('mounting profile display')
user = await fetch('http://{Domain}:{Port}/api/v2/user') user = await fetch(`http://${Domain}:${Port}/api/v2/user`)
.then( (x) => x.json() ); .then( (x) => x.json() );
}) })

View File

@@ -39,7 +39,7 @@ could be a list of friends and if they're active but i can't see that yet
onMount( async() => { onMount( async() => {
// yea no idea what // yea no idea what
// i mean do i fetch user? i will for now // i mean do i fetch user? i will for now
user = await fetch('http://{Domain}:{Port}/api/v2/user') user = await fetch(`http://${Domain}:${Port}/api/v2/user`)
.then( (x) => x.json() ); .then( (x) => x.json() );
// userBeingViewed = user; // userBeingViewed = user;
@@ -47,26 +47,26 @@ could be a list of friends and if they're active but i can't see that yet
// console.log(user) // console.log(user)
// console.log(user.username) // console.log(user.username)
myFriends = await fetch("http://{Domain}:{Port}/api/v2/network/myfriends") myFriends = await fetch(`http://${Domain}:${Port}/api/v2/network/myfriends`)
.then( (x) => x.json() ); .then( (x) => x.json() );
// console.log('my friends') // console.log('my friends')
// console.log(myFriends) // console.log(myFriends)
requestsMade = await fetch('http://{Domain}:{Port}/api/v2/network/pending') requestsMade = await fetch(`http://${Domain}:${Port}/api/v2/network/pending`)
.then( x => x.json() ); .then( x => x.json() );
// console.log('Requests pending '); // console.log('Requests pending ');
// console.log(requestsMade); // console.log(requestsMade);
requestsRecieved = await fetch('http://{Domain}:{Port}/api/v2/network/received') requestsRecieved = await fetch(`http://${Domain}:${Port}/api/v2/network/received`)
.then( x => x.json() ); .then( x => x.json() );
// console.log('Requests received '); // console.log('Requests received ');
// console.log(requestsRecieved); // console.log(requestsRecieved);
allUsers = await fetch('http://{Domain}:{Port}/api/v2/user/all') allUsers = await fetch(`http://${Domain}:${Port}/api/v2/user/all`)
.then( x => x.json() ); .then( x => x.json() );
// console.log('got all users ' + allUsers) // console.log('got all users ' + allUsers)
@@ -75,20 +75,20 @@ could be a list of friends and if they're active but i can't see that yet
const displayAllUsers = async() => { const displayAllUsers = async() => {
allUsers = await fetch('http://{Domain}:{Port}/api/v2/user/all') allUsers = await fetch(`http://${Domain}:${Port}/api/v2/user/all`)
.then( x => x.json() ); .then( x => x.json() );
// console.log('got all users ' + allUsers) // console.log('got all users ' + allUsers)
}; };
const displayAllFriends = async() => { const displayAllFriends = async() => {
myFriends = await fetch('http://{Domain}:{Port}/api/v2/network/myfriends') myFriends = await fetch(`http://${Domain}:${Port}/api/v2/network/myfriends`)
.then( x => x.json() ); .then( x => x.json() );
// console.log('got all friends ' + allFriends) // console.log('got all friends ' + allFriends)
}; };
const displayRequestsMade = async() => { const displayRequestsMade = async() => {
requestsMade = await fetch('http://{Domain}:{Port}/api/v2/network/pending') requestsMade = await fetch(`http://${Domain}:${Port}/api/v2/network/pending`)
.then( x => x.json() ); .then( x => x.json() );
// console.log('got requests made ' + requestsMade) // console.log('got requests made ' + requestsMade)
}; };
@@ -107,7 +107,7 @@ could be a list of friends and if they're active but i can't see that yet
} }
if (valid) { if (valid) {
sentFriendRequest = await fetch("http://{Domain}:{Port}/api/v2/network/myfriends", { sentFriendRequest = await fetch(`http://${Domain}:${Port}/api/v2/network/myfriends`, {
method : "POST", method : "POST",
headers: { 'Content-Type': 'application/json'}, headers: { 'Content-Type': 'application/json'},
body: JSON.stringify({ body: JSON.stringify({
@@ -125,7 +125,7 @@ could be a list of friends and if they're active but i can't see that yet
// sendUsername = userBeingViewed.username; // sendUsername = userBeingViewed.username;
// prolly like fetch if you're friends or not? // prolly like fetch if you're friends or not?
// GET http://{Domain}:{Port}/api/v2/networks/myfriends?username=aUser but i need to make that as long as Cherif // GET `http://${Domain}:${Port}/api/v2/networks/myfriends?username=aUser` but i need to make that as long as Cherif
// doesn't have a better option // doesn't have a better option
// like i want this thing to return the Friendship ID ideally // like i want this thing to return the Friendship ID ideally
}; };

View File

@@ -17,7 +17,7 @@
let success = {username: '', avatar: '' }; let success = {username: '', avatar: '' };
onMount( async() => { onMount( async() => {
user = await fetch('http://{Domain}:{Port}/api/v2/user') user = await fetch(`http://${Domain}:${Port}/api/v2/user`)
.then( (x) => x.json() ); .then( (x) => x.json() );
// do a .catch? // do a .catch?
@@ -34,7 +34,7 @@
// console.log('this is what is in the avatar before fetch') // console.log('this is what is in the avatar before fetch')
// console.log(avatar) // console.log(avatar)
await fetch("http://{Domain}:{Port}/api/v2/user/avatar", {method: "GET"}) await fetch(`http://${Domain}:${Port}/api/v2/user/avatar`, {method: "GET"})
.then(response => {return response.blob()}) .then(response => {return response.blob()})
.then(data => { .then(data => {
const url = URL.createObjectURL(data); const url = URL.createObjectURL(data);
@@ -64,7 +64,7 @@
else { else {
errors.username = ''; errors.username = '';
} }
await fetch('http://{Domain}:{Port}/api/v2/user',{ await fetch(`http://${Domain}:${Port}/api/v2/user`, {
method: 'PATCH', method: 'PATCH',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
@@ -101,7 +101,7 @@
// tmp // tmp
console.log(data); console.log(data);
await fetch("http://{Domain}:{Port}/api/v2/user/avatar", await fetch(`http://${Domain}:${Port}/api/v2/user/avatar`,
{ {
method : 'POST', method : 'POST',
body : data, body : data,
@@ -109,7 +109,7 @@
.then(() => uploadAvatarSuccess = true ) // for some reason it needs to be a function, i think a TS thing, not a promis otherwise .then(() => uploadAvatarSuccess = true ) // for some reason it needs to be a function, i think a TS thing, not a promis otherwise
.then(() => success.avatar = 'Your changes have been saved') .then(() => success.avatar = 'Your changes have been saved')
.catch(() => errors.avatar = 'Sorry failed to upload your new Avatar' ); .catch(() => errors.avatar = 'Sorry failed to upload your new Avatar' );
await fetch("http://{Domain}:{Port}/api/v2/user/avatar", {method: "GET"}) await fetch(`http://${Domain}:${Port}/api/v2/user/avatar`, {method: "GET"})
.then(response => {return response.blob()}) .then(response => {return response.blob()})
.then(data => { .then(data => {
const url = URL.createObjectURL(data); const url = URL.createObjectURL(data);

View File

@@ -10,8 +10,8 @@
onMount( async() => { onMount( async() => {
console.log('Display aUser username: '+ aUsername) console.log('Display aUser username: '+ aUsername)
// http://{Domain}:{Port}/api/v2/user?username=NomDuUserATrouver //`http://${Domain}:${Port}/api/v2/user?username=NomDuUserATrouve`
user = await fetch(`http://{Domain}:{Port}/api/v2/user?username=${aUsername}`) user = await fetch(`http://${Domain}:${Port}/api/v2/user?username=${aUsername}`)
.then( (x) => x.json() ); .then( (x) => x.json() );
// console.log('Display a user: ') // console.log('Display a user: ')
@@ -27,15 +27,15 @@
const updateUser = async(updatedUser) => { const updateUser = async(updatedUser) => {
console.log('Display Update aUser username: '+ updateUser) console.log('Display Update aUser username: '+ updateUser)
// http://{Domain}:{Port}/api/v2/user?username=NomDuUserATrouver //`http://${Domain}:${Port}/api/v2/user?username=NomDuUserATrouve`
user = await fetch(`http://{Domain}:{Port}/api/v2/user?username=${updateUser}`) user = await fetch(`http://${Domain}:${Port}/api/v2/user?username=${updateUser}`)
.then( (x) => x.json() ); .then( (x) => x.json() );
}; };
// export const updateUser = async(updatedUser) => { // export const updateUser = async(updatedUser) => {
// console.log('Display Update aUser username: '+ updateUser) // console.log('Display Update aUser username: '+ updateUser)
// // http://{Domain}:{Port}/api/v2/user?username=NomDuUserATrouver // //`http://${Domain}:${Port}/api/v2/user?username=NomDuUserATrouve`
// user = await fetch(`http://{Domain}:{Port}/api/v2/user?username=${updateUser}`) // user = await fetch(`http://${Domain}:${Port}/api/v2/user?username=${updateUser}`)
// .then( (x) => x.json() ); // .then( (x) => x.json() );
// updateGeneratedUser(updateUser); // updateGeneratedUser(updateUser);

View File

@@ -12,7 +12,7 @@
onMount( async() => { onMount( async() => {
// using this for now cuz for some reason there is yet to be a way to fet another person's avatar // using this for now cuz for some reason there is yet to be a way to fet another person's avatar
if (primary) { if (primary) {
await fetch("http://{Domain}:{Port}/api/v2/user/avatar", {method: "GET"}) await fetch(`http://${Domain}:${Port}/api/v2/user/avatar`, {method: "GET"})
.then(response => {return response.blob()}) .then(response => {return response.blob()})
.then(data => { .then(data => {
const url = URL.createObjectURL(data); const url = URL.createObjectURL(data);

View File

@@ -8,7 +8,7 @@
let handleClickLogout = async () => { let handleClickLogout = async () => {
await fetch('http://{Domain}:{Port}/api/v2/auth/logout', { await fetch(`http://${Domain}:${Port}/api/v2/auth/logout`, {
method: 'POST', method: 'POST',
}) })
// .then(resp => resp.json) // .then(resp => resp.json)

View File

@@ -2,14 +2,14 @@
<script lang="ts"> <script lang="ts">
import Layouts from './Chat_layouts.svelte'; import Layouts from './Chat_layouts.svelte';
import { Domain, Port } from "../Constantes.svelte"; import { Domain, PortIo } from "../../Constantes.svelte";
export let color = "transparent"; export let color = "transparent";
/* web sockets with socket.io /* web sockets with socket.io
*/ */
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import io from 'socket.io-client'; import io from 'socket.io-client';
const socket = io('http://{Domain}:{Port}', { const socket = io(`http://${Domain}:${PortIo}`, {
path: '/chat' path: '/chat'
}); });
onMount(async => { onMount(async => {