Compare commits
10 Commits
f4dab8360d
...
f7019403c4
| Author | SHA1 | Date | |
|---|---|---|---|
| f7019403c4 | |||
| f5b8b86105 | |||
| a823fafc09 | |||
| 67c75578e5 | |||
| c6cf7cc88b | |||
| aa71a7a3cc | |||
| 41c9bdafaf | |||
| 2fa6740aac | |||
| 9992386624 | |||
| 8e15699cd1 |
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
||||
FROM arm64v8/node:25-alpine
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
COPY build .
|
||||
RUN apk add mariadb-client
|
||||
RUN npm install
|
||||
|
||||
EXPOSE 4000
|
||||
|
||||
CMD [ "node", "server/index.js" ]
|
||||
50
build.sh
@@ -1,27 +1,63 @@
|
||||
#!/bin/sh
|
||||
|
||||
# create folder to pack all
|
||||
echo "Starting build process..."
|
||||
mkdir build
|
||||
cd main-web/client
|
||||
npm run build
|
||||
cd ../../
|
||||
mv main-web/client/client build
|
||||
|
||||
# build janken tool and move
|
||||
cd tools/janken
|
||||
echo "Starting janken tool build..."
|
||||
npm run build
|
||||
cd ../../
|
||||
mv tools/janken/tool build
|
||||
echo "Finished janken tool build..."
|
||||
|
||||
# build client and move
|
||||
cd main-web/client
|
||||
echo "Starting client build..."
|
||||
npm run build
|
||||
cd ../../
|
||||
mv main-web/client/client build
|
||||
echo "Finished client build..."
|
||||
|
||||
# build admin and move
|
||||
cd main-web/admin
|
||||
echo "Starting admin ui build..."
|
||||
npm run build
|
||||
cd ../../
|
||||
mv main-web/admin/build build/admin
|
||||
echo "Finished admin ui build..."
|
||||
|
||||
# build server and move
|
||||
cd main-web/server
|
||||
echo "Starting server build..."
|
||||
npm run build
|
||||
cd ../../
|
||||
cd build/
|
||||
echo "Starting retrieval of db credentials..."
|
||||
export catherine_db_endpoint=$(aws --region=ap-northeast-1 ssm get-parameter --name "db-endpoint" --with-decryption --output text --query Parameter.Value)
|
||||
export catherine_db_user=$(aws --region=ap-northeast-1 ssm get-parameter --name "db-username" --with-decryption --output text --query Parameter.Value)
|
||||
export catherine_db_pass=$(aws --region=ap-northeast-1 ssm get-parameter --name "db-password" --with-decryption --output text --query Parameter.Value)
|
||||
echo "Saving db credentials to .env file..."
|
||||
cat > .env <<EOL
|
||||
DB_ENDPOINT=${catherine_db_endpoint}
|
||||
DB_USER=${catherine_db_user}
|
||||
DB_PASS=${catherine_db_pass}
|
||||
EOL
|
||||
npm run build
|
||||
cd ../../
|
||||
cp main-web/server/.env build/
|
||||
cd ../
|
||||
cp main-web/server/package.json build/
|
||||
cp main-web/server/tsconfig.json build/
|
||||
cp main-web/server/tslint.json build/
|
||||
mv main-web/server/build build/server
|
||||
echo "Finished server build..."
|
||||
|
||||
echo "Compressing all files..."
|
||||
tar czf build.tar.gz build/
|
||||
echo "Finished compressing all files..."
|
||||
echo "Removing workfolder..."
|
||||
rm -rf build/
|
||||
echo "Removed workfolder..."
|
||||
|
||||
echo "Upload built files to s3..."
|
||||
aws s3 cp build.tar.gz s3://catherine-fc-infra/
|
||||
echo "Finished build process..."
|
||||
|
||||
40
build_script.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
# create folder to pack all
|
||||
echo "Starting build process..."
|
||||
mkdir build
|
||||
|
||||
# build janken tool and move
|
||||
cd tools/janken
|
||||
echo "Starting janken tool build..."
|
||||
npm install
|
||||
npm run build
|
||||
cd ../../
|
||||
mv tools/janken/tool build
|
||||
echo "Finished janken tool build..."
|
||||
|
||||
# build client and move
|
||||
cd main-web/client
|
||||
echo "Starting client build..."
|
||||
npm install
|
||||
npm run build
|
||||
cd ../../
|
||||
mv main-web/client/client build/client
|
||||
echo "Finished client build..."
|
||||
|
||||
# build server and move
|
||||
cd main-web/server
|
||||
echo "Starting server build..."
|
||||
npm install
|
||||
npm run build
|
||||
cd ../../
|
||||
cd build/
|
||||
|
||||
echo "Saving db credentials to .env file..."
|
||||
|
||||
cd ../
|
||||
cp main-web/server/package.json build/
|
||||
cp main-web/server/tsconfig.json build/
|
||||
cp main-web/server/tslint.json build/
|
||||
mv main-web/server/build build/server
|
||||
echo "Finished server build..."
|
||||
@@ -7,5 +7,3 @@
|
||||
1. assume $env is one of ~~nonprod, uat,~~ prod
|
||||
2. $ cd packer
|
||||
3. $ packer build -var-file=vars/${env}/vars.json catherine-fc.json
|
||||
|
||||
|
||||
|
||||
@@ -150,3 +150,14 @@ CREATE TABLE `catherine_league`.`archive` (
|
||||
|
||||
INSERT INTO `catherine_league`.`archive` (`title`, `youtube_id`) VALUES ('格ゲー大好き茜ちゃんと競う『キャサリン・フルボディ』 【VOICEROID紹介動画】', 'oE8Xk6pGtQc');
|
||||
INSERT INTO `catherine_league`.`archive` (`title`, `youtube_id`) VALUES ('【PGW.TV】キャサリンフルボディ 「対戦時に使うテクニック紹介など」【はやお】', '7fZk2Agy0S4');
|
||||
|
||||
CREATE TABLE catherine_league.janken (
|
||||
id BIGINT UNSIGNED auto_increment NOT NULL,
|
||||
`match` varchar(100) NULL,
|
||||
`result` json NULL,
|
||||
created_date DATETIME DEFAULT NOW() NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb4
|
||||
COLLATE=utf8mb4_general_ci;
|
||||
|
||||
23
infra/terraform/modules/catherine-fc/main/cognito.tf
Normal file
@@ -0,0 +1,23 @@
|
||||
resource "aws_cognito_user_pool" "catherine_fc_admin_cognito_pool" {
|
||||
name = "catherine-fc-admin"
|
||||
|
||||
admin_create_user_config {
|
||||
allow_admin_create_user_only = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_cognito_user_pool_client" "catherine_fc_admin_cognito_pool_client" {
|
||||
name = "catherine-fc-admin-client"
|
||||
user_pool_id = aws_cognito_user_pool.catherine_fc_admin_cognito_pool.id
|
||||
allowed_oauth_flows = ["code","implicit"]
|
||||
allowed_oauth_scopes = ["email", "openid"]
|
||||
callback_urls = ["https://www.catherine-fc.com","https://catherine-fc.com"]
|
||||
allowed_oauth_flows_user_pool_client = true
|
||||
generate_secret = true
|
||||
explicit_auth_flows = ["USER_PASSWORD_AUTH"]
|
||||
}
|
||||
|
||||
resource "aws_cognito_user_pool_domain" "catherine_fc_admin_cognito_pool_domain" {
|
||||
domain = "catherine-fc-admin-domain"
|
||||
user_pool_id = aws_cognito_user_pool.catherine_fc_admin_cognito_pool.id
|
||||
}
|
||||
@@ -21,3 +21,57 @@ resource "aws_lb_listener" "catherine_fc_load_balancer_listener" {
|
||||
target_group_arn = aws_lb_target_group.target_group_web.arn
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_lb_listener_rule" "catherine_fc_alb_listener_admin" {
|
||||
listener_arn = aws_lb_listener.catherine_fc_load_balancer_listener.arn
|
||||
priority = 1
|
||||
action {
|
||||
type = "authenticate-cognito"
|
||||
|
||||
authenticate_cognito {
|
||||
user_pool_arn = aws_cognito_user_pool.catherine_fc_admin_cognito_pool.arn
|
||||
user_pool_client_id = aws_cognito_user_pool_client.catherine_fc_admin_cognito_pool_client.id
|
||||
user_pool_domain = aws_cognito_user_pool_domain.catherine_fc_admin_cognito_pool_domain.domain
|
||||
on_unauthenticated_request = "authenticate"
|
||||
session_cookie_name = "CatherineFCAdmin"
|
||||
session_timeout = 86400
|
||||
}
|
||||
}
|
||||
action {
|
||||
type = "forward"
|
||||
target_group_arn = aws_lb_target_group.target_group_web.arn
|
||||
}
|
||||
|
||||
condition {
|
||||
path_pattern {
|
||||
values = ["/admin*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_lb_listener_rule" "catherine_fc_alb_listener_admin_api" {
|
||||
listener_arn = aws_lb_listener.catherine_fc_load_balancer_listener.arn
|
||||
priority = 2
|
||||
action {
|
||||
type = "authenticate-cognito"
|
||||
|
||||
authenticate_cognito {
|
||||
user_pool_arn = aws_cognito_user_pool.catherine_fc_admin_cognito_pool.arn
|
||||
user_pool_client_id = aws_cognito_user_pool_client.catherine_fc_admin_cognito_pool_client.id
|
||||
user_pool_domain = aws_cognito_user_pool_domain.catherine_fc_admin_cognito_pool_domain.domain
|
||||
on_unauthenticated_request = "deny"
|
||||
session_cookie_name = "CatherineFCAdmin"
|
||||
session_timeout = 86400
|
||||
}
|
||||
}
|
||||
action {
|
||||
type = "forward"
|
||||
target_group_arn = aws_lb_target_group.target_group_web.arn
|
||||
}
|
||||
|
||||
condition {
|
||||
path_pattern {
|
||||
values = ["/api/admin*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
{
|
||||
"name": "discord-commentator",
|
||||
"name": "catherine-fc-admin-ui",
|
||||
"version": "0.1.0",
|
||||
"homepage": "./",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"discord-rpc": "^3.1.3",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-scripts": "3.4.1",
|
||||
"typescript": "^3.7.5"
|
||||
"node-sass": "^4.13.1",
|
||||
"semantic-ui-css": "^2.4.1",
|
||||
"semantic-ui-react": "^0.88.2",
|
||||
"i18next": "^19.6.3",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
@@ -15,9 +19,11 @@
|
||||
"@testing-library/user-event": "^7.2.1",
|
||||
"@types/jest": "^24.9.1",
|
||||
"@types/node": "^12.12.54",
|
||||
"@types/react": "^16.9.44",
|
||||
"@types/react": "^16.9.45",
|
||||
"@types/react-dom": "^16.9.8",
|
||||
"@types/discord-rpc": "^3.0.4"
|
||||
"tslint": "^5.18.0",
|
||||
"tslint-config-airbnb": "^5.11.1",
|
||||
"tslint-react": "^4.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
BIN
main-web/admin/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 134 KiB |
42
main-web/admin/public/index.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Admin UI for catherine-fc"
|
||||
/>
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>Catherine Faito Crab Admin UI</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
9
main-web/admin/public/manifest.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
11
main-web/admin/src/App.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import './App.css';
|
||||
|
||||
function App(): JSX.Element {
|
||||
return (
|
||||
<div className="App">
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
"axios": "^0.21.1",
|
||||
"dotenv": "^8.2.0",
|
||||
"i18next": "^19.6.3",
|
||||
"node-sass": "^4.13.1",
|
||||
@@ -15,13 +15,13 @@
|
||||
"react-youtube": "^7.11.3",
|
||||
"semantic-ui-css": "^2.4.1",
|
||||
"semantic-ui-react": "^0.88.2",
|
||||
"typescript": "^3.7.5"
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.5.0",
|
||||
"@testing-library/user-event": "^7.2.1",
|
||||
"@types/react-router-dom": "^5.1.5",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"@types/jest": "^24.9.1",
|
||||
"@types/node": "^12.12.35",
|
||||
"@types/react": "^16.9.34",
|
||||
|
||||
@@ -1,23 +1,7 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"icons": [],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
|
||||
@@ -47,12 +47,20 @@ function App(): JSX.Element {
|
||||
<li>
|
||||
<Link to='/'>Home</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link to='/players'>Players</Link>
|
||||
</li>
|
||||
{
|
||||
/*
|
||||
|
||||
<li>
|
||||
<Link to='/tournaments/stray_sheep_0/players'>Players</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link to='/tournaments/stray_sheep_0/scoreboard'>Scoreboard</Link>
|
||||
</li>
|
||||
*/
|
||||
}
|
||||
<li>
|
||||
<Link to='/guide'>Guide</Link>
|
||||
</li>
|
||||
|
||||
@@ -5,22 +5,24 @@ type ComponentProps = {
|
||||
};
|
||||
|
||||
export const Home: FunctionComponent<ComponentProps> = (props): JSX.Element => {
|
||||
|
||||
return (
|
||||
<div className={style.mainBody}>
|
||||
<div className={style.chalice} />
|
||||
<div className={style.titleImageStrayShip0} />
|
||||
<div className={style.players} />
|
||||
<div className={style.evojapan2025} />
|
||||
<div className={style.padding} />
|
||||
<div className={style.rule} />
|
||||
<div className={style.twitchHome}>
|
||||
<a href='https://www.twitch.tv/catherine_faito_crab' rel='noopener noreferrer' target='_blank'> </a>
|
||||
<div className={style.evojapan2023kaisaikettei} />
|
||||
<div className={style.padding} />
|
||||
<div className={style.group}>
|
||||
<div className={style.evojapan2023catherinetonamel}>
|
||||
<a href='https://tonamel.com/competition/VD6y8' rel='noopener noreferrer' target='_blank'> </a>
|
||||
</div>
|
||||
<div className={style.evojapan2023catherinefullbodytonamel}>
|
||||
<a href='https://tonamel.com/competition/dgdQ9' rel='noopener noreferrer' target='_blank'> </a>
|
||||
</div>
|
||||
</div>
|
||||
<div className={style.padding} />
|
||||
<div className={style.twitchHome}>
|
||||
<a href='https://www.twitch.tv/catherine_faito_crab' rel='noopener noreferrer' target='_blank'> </a>
|
||||
</div>
|
||||
<div className={style.players0801} />
|
||||
<div className={style.players0802} />
|
||||
<div className={style.players0808} />
|
||||
<div className={style.players0809} />
|
||||
<div className={style.players0815} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@ type ComponentProps = {
|
||||
export const Players: FunctionComponent<ComponentProps> = (props): JSX.Element => {
|
||||
const { t } = useTranslation();
|
||||
const [playerInfo, setPlayerInfo] = useState<IPlayerInfo[]>([]);
|
||||
// @ts-ignore
|
||||
const { tournament_key } = useParams();
|
||||
useEffect(() => {
|
||||
if (playerInfo.length === 0) {
|
||||
|
||||
@@ -440,6 +440,69 @@
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
}
|
||||
.evojapan2023 {
|
||||
width: 500px;
|
||||
height: 471px;
|
||||
margin: auto;
|
||||
background-image: url('https://static.catherine-fc.com/media/evo_logo_shadow_drop.png');
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
}
|
||||
.evojapan2024 {
|
||||
width: 500px;
|
||||
height: 471px;
|
||||
margin: auto;
|
||||
background-image: url('https://static.catherine-fc.com/media/evo_2024_logo_shadow_drop.png');
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
}
|
||||
.evojapan2025 {
|
||||
width: 500px;
|
||||
height: 471px;
|
||||
margin: auto;
|
||||
background-image: url('https://static.catherine-fc.com/media/evo_logo_2025_shadow_drop.png');
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
}
|
||||
.evojapan2023kaisaikettei {
|
||||
width: 846px;
|
||||
height: 285px;
|
||||
margin: auto;
|
||||
background-image: url('https://static.catherine-fc.com/media/kaisaikettei3.png');
|
||||
background-size: contain;
|
||||
}
|
||||
.evojapan2023catherinetonamel {
|
||||
width: 412px;
|
||||
height: 389px;
|
||||
background-image: url('https://static.catherine-fc.com/media/catherine_logo_classic.png');
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
&> a {
|
||||
display:block;
|
||||
width: 412px;
|
||||
height: 389px;
|
||||
}
|
||||
}
|
||||
.evojapan2023catherinefullbodytonamel {
|
||||
width: 517px;
|
||||
height: 319px;
|
||||
background-image: url('https://static.catherine-fc.com/media/catherine_fullbody_logo.png');
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
&> a {
|
||||
display:block;
|
||||
width: 517px;
|
||||
height: 319px;
|
||||
}
|
||||
}
|
||||
.group {
|
||||
width: 900px;
|
||||
height: 389px;
|
||||
margin: auto;
|
||||
display: flex;
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
}
|
||||
.players {
|
||||
width: 900px;
|
||||
height: 606px;
|
||||
@@ -464,6 +527,14 @@
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
}
|
||||
.titleImageStrayShip4 {
|
||||
width: 808px;
|
||||
height: 119px;
|
||||
margin: auto;
|
||||
background-image: url('https://static.catherine-fc.com/media/straysheepcup4.png');
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
}
|
||||
.rule {
|
||||
width: 900px;
|
||||
height: 637px;
|
||||
@@ -472,7 +543,19 @@
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
}
|
||||
|
||||
.tonamel {
|
||||
width: 900px;
|
||||
height: 637px;
|
||||
margin: auto;
|
||||
background-image: url('https://static.catherine-fc.com/media/tonamel.png');
|
||||
background-size: contain;
|
||||
background-repeat: none;
|
||||
&> a {
|
||||
display:block;
|
||||
width: 900px;
|
||||
height: 637px;
|
||||
}
|
||||
}
|
||||
.padding {
|
||||
width: 900px;
|
||||
height: 100px;
|
||||
|
||||
2
main-web/server/.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
admin/
|
||||
client/
|
||||
build/
|
||||
.env
|
||||
.env*
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
"start": "ts-node-dev --respawn --transpileOnly ./src/index.ts",
|
||||
"start": "ts-node-dev --poll --respawn --transpile-only ./src/index.ts",
|
||||
"build": "tsc --resolveJsonModule",
|
||||
"test": "ts-node-dev src/test.ts",
|
||||
"lint": "tslint -c tslint.json -p tsconfig.json"
|
||||
@@ -24,7 +24,7 @@
|
||||
"@types/express": "^4.17.6",
|
||||
"@types/mysql": "^2.1.4",
|
||||
"@types/socket.io": "^2.1.4",
|
||||
"typescript": "^3.8.3",
|
||||
"typescript": "^4.9.5",
|
||||
"tslint": "^5.18.0",
|
||||
"tslint-config-airbnb": "^5.11.1"
|
||||
}
|
||||
|
||||
@@ -7,21 +7,25 @@ import dotenv from 'dotenv';
|
||||
import { v1 } from 'uuid';
|
||||
|
||||
import { IJankenSelect, IJankenResult } from './models/message';
|
||||
import { IRoom } from './models';
|
||||
|
||||
dotenv.config();
|
||||
const port: number = 8080;
|
||||
const port: number = 4000;
|
||||
const app: express.Express = express();
|
||||
const httpServer: http.Server = http.createServer(app);
|
||||
const io: socketIo.Server = socketIo(httpServer);
|
||||
|
||||
const tournaments: Record<string, number> = {};
|
||||
const players: Record<string, number> = {};
|
||||
console.log(process.env.DB_ENDPOINT);
|
||||
const connection = mysql.createPool({
|
||||
connectionLimit: 10,
|
||||
host: 'catherine-fc.csmrqtei38qi.ap-northeast-1.rds.amazonaws.com',
|
||||
port: (process.env.DB_PORT ? parseInt(process.env.DB_PORT, 10) : 3306),
|
||||
host: process.env.DB_ENDPOINT,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASS,
|
||||
database: 'catherine_league'
|
||||
database: 'catherine_league',
|
||||
charset: 'utf8mb4'
|
||||
});
|
||||
connection.query(
|
||||
`SELECT id, tournament_key
|
||||
@@ -139,6 +143,7 @@ app.get('/api/contact', (req: any, res: any) => {
|
||||
);
|
||||
});
|
||||
|
||||
app.use('/admin', express.static('admin'));
|
||||
app.use('/players', express.static('client'));
|
||||
app.use('/tournaments*', express.static('client'));
|
||||
app.use('/about', express.static('client'));
|
||||
@@ -154,16 +159,11 @@ httpServer.listen(port, () => {
|
||||
|
||||
// Janken Tool
|
||||
|
||||
let room: boolean = false;
|
||||
let playerOne: string = '';
|
||||
let playerTwo: string = '';
|
||||
let playerOneOption: string = '';
|
||||
let playerTwoOption: string = '';
|
||||
let stages: string[] = [];
|
||||
let currentIndex: number = 0;
|
||||
let rooms: Record<string, IRoom> = {};
|
||||
const defaultStages: string[] = ['cementery', 'prison', 'torture', 'inquisition', 'quadrangle', 'clock', 'spiral', 'empireo', 'cathedral', 'close', 'arrange'];
|
||||
|
||||
|
||||
io.on('connection', (socket: socketIo.Socket) => {
|
||||
socket.on('disconnect', () => {
|
||||
console.log('disconnect');
|
||||
@@ -172,46 +172,74 @@ io.on('connection', (socket: socketIo.Socket) => {
|
||||
socket.on('exitGame', () => {
|
||||
console.log('exitGame');
|
||||
io.emit('exitGame');
|
||||
room = false;
|
||||
initRoom();
|
||||
Object.keys(io.sockets.sockets).forEach((s) => {
|
||||
rooms = {};
|
||||
Object.keys(io.sockets.sockets).forEach((s: string) => {
|
||||
io.sockets.sockets[s].disconnect(true);
|
||||
});
|
||||
});
|
||||
socket.on('janken', (data: IJankenSelect) => {
|
||||
console.log('janken', data);
|
||||
if (playerOne === data.userName) {
|
||||
playerOneOption = data.option;
|
||||
} else if (playerTwo === data.userName) {
|
||||
playerTwoOption = data.option;
|
||||
}
|
||||
console.log('playerOneOption',playerOneOption);
|
||||
console.log('playerTwoOption',playerTwoOption);
|
||||
if (playerOneOption !== '' && playerTwoOption !== '') {
|
||||
const message: IJankenResult = {
|
||||
playerOne,
|
||||
playerOneOption,
|
||||
playerTwo,
|
||||
playerTwoOption
|
||||
const currentRoom = rooms[data.room];
|
||||
if (currentRoom) {
|
||||
if (currentRoom.playerOne === data.userName) {
|
||||
currentRoom.playerOneOption = data.option;
|
||||
} else if (currentRoom.playerTwo === data.userName) {
|
||||
currentRoom.playerTwoOption = data.option;
|
||||
}
|
||||
console.log('playerOneOption', currentRoom.playerOneOption);
|
||||
console.log('playerTwoOption', currentRoom.playerTwoOption);
|
||||
if (currentRoom.playerOneOption !== '' && currentRoom.playerTwoOption !== '') {
|
||||
const message: IJankenResult = {
|
||||
playerOne: currentRoom.playerOne,
|
||||
playerOneOption: currentRoom.playerOneOption,
|
||||
playerTwo: currentRoom.playerTwo,
|
||||
playerTwoOption: currentRoom.playerTwoOption
|
||||
};
|
||||
io.to(data.room).emit('jankenResult', message);
|
||||
const sqlToPrepare = 'INSERT INTO `janken` (`match`, `result`) VALUES(?, ?);';
|
||||
const sql = mysql.format(sqlToPrepare, [data.room, JSON.stringify(message)]);
|
||||
connection.query(sql,
|
||||
(error: mysql.MysqlError | null, results: any) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (currentRoom.playerOneOption !== currentRoom.playerTwoOption) {
|
||||
delete rooms[data.room];
|
||||
}
|
||||
}
|
||||
io.emit('jankenResult', message);
|
||||
}
|
||||
});
|
||||
socket.on('registerUser', (data: string) => {
|
||||
socket.on('registerUser', (data: {username: string, room: string}) => {
|
||||
console.log('registerUser', data);
|
||||
if (playerOne === '') {
|
||||
playerOne = data;
|
||||
socket.emit('registerUser', data);
|
||||
} else if (playerTwo === '') {
|
||||
playerTwo = data;
|
||||
socket.emit('registerUser', data);
|
||||
let currentRoom: IRoom = {
|
||||
playerOne: '',
|
||||
playerTwo: '',
|
||||
playerOneOption: '',
|
||||
playerTwoOption: ''
|
||||
};
|
||||
if (rooms[data.room]) {
|
||||
currentRoom = rooms[data.room];
|
||||
} else {
|
||||
rooms = {
|
||||
...rooms,
|
||||
[data.room]: currentRoom
|
||||
};
|
||||
}
|
||||
socket.join(data.room);
|
||||
if (currentRoom.playerOne === '') {
|
||||
currentRoom.playerOne = data.username;
|
||||
socket.emit('registerUser', data.username);
|
||||
} else if (currentRoom.playerTwo === '') {
|
||||
currentRoom.playerTwo = data.username;
|
||||
socket.emit('registerUser', data.username);
|
||||
}
|
||||
const message = {
|
||||
playerOne: playerOne,
|
||||
playerTwo: playerTwo,
|
||||
playerOne: currentRoom.playerOne,
|
||||
playerTwo: currentRoom.playerTwo
|
||||
};
|
||||
console.log()
|
||||
io.emit('login', message);
|
||||
io.to(data.room).emit('login', message);
|
||||
});
|
||||
socket.on('moveToStage', () => {
|
||||
console.log('moveToStage');
|
||||
@@ -226,11 +254,14 @@ io.on('connection', (socket: socketIo.Socket) => {
|
||||
io.emit('updateIndex', currentIndex);
|
||||
}
|
||||
});
|
||||
socket.on('againGame', () => {
|
||||
console.log('againGame');
|
||||
io.emit('againGame');
|
||||
playerOneOption = '';
|
||||
playerTwoOption = '';
|
||||
socket.on('againGame', (room: string) => {
|
||||
const currentRoom = rooms[room];
|
||||
if (currentRoom) {
|
||||
console.log('againGame');
|
||||
io.to(room).emit('againGame');
|
||||
currentRoom.playerOneOption = '';
|
||||
currentRoom.playerTwoOption = '';
|
||||
}
|
||||
});
|
||||
socket.on('previousIndex', () => {
|
||||
console.log('previousIndex');
|
||||
@@ -239,6 +270,7 @@ io.on('connection', (socket: socketIo.Socket) => {
|
||||
io.emit('updateIndex', currentIndex);
|
||||
}
|
||||
});
|
||||
/*
|
||||
if (!room) {
|
||||
// create new room
|
||||
initRoom();
|
||||
@@ -248,31 +280,29 @@ io.on('connection', (socket: socketIo.Socket) => {
|
||||
playerTwo: '',
|
||||
};
|
||||
socket.emit('login', message);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (playerOne === '' || playerTwo === '' || playerOneOption === '' || playerTwoOption === '') {
|
||||
const message = {
|
||||
playerOne: playerOne,
|
||||
playerTwo: playerTwo,
|
||||
playerOne,
|
||||
playerTwo,
|
||||
};
|
||||
socket.emit('login', message);
|
||||
} else {
|
||||
const message = {
|
||||
stages,
|
||||
currentIndex
|
||||
}
|
||||
};
|
||||
socket.emit('stages', message);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
const initialmessage = {
|
||||
playerOne: '',
|
||||
playerTwo: '',
|
||||
};
|
||||
socket.emit('login', initialmessage);
|
||||
});
|
||||
const shuffle = (array: string[]): string[] => {
|
||||
return array.sort(() => Math.random() - 0.5);
|
||||
};
|
||||
|
||||
const initRoom = (): void => {
|
||||
playerOne = '';
|
||||
playerTwo = '';
|
||||
playerOneOption = '';
|
||||
playerTwoOption = '';
|
||||
};
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface IRoom {
|
||||
playerOne: string;
|
||||
playerTwo: string;
|
||||
playerOneOption: string;
|
||||
playerTwoOption: string;
|
||||
}
|
||||
|
||||
@@ -16,5 +16,6 @@ export interface ILogin {
|
||||
|
||||
export interface IJankenSelect {
|
||||
userName: string;
|
||||
room: string;
|
||||
option: string;
|
||||
}
|
||||
|
||||
1
main-web/serverless/go/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
pkg/
|
||||
BIN
main-web/serverless/go/bin/go-outline
Normal file
BIN
main-web/serverless/go/bin/gopls
Normal file
21
main-web/serverless/go/src/catherine-fc-api/.gitignore
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Serverless directories
|
||||
.serverless
|
||||
|
||||
# golang output binary directory
|
||||
bin
|
||||
|
||||
# golang vendor (dependencies) directory
|
||||
vendor
|
||||
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
91
main-web/serverless/go/src/catherine-fc-api/Gopkg.lock
generated
Normal file
@@ -0,0 +1,91 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
digest = "1:1f2ee62e40b3b0ca8403e49a07afb9ae8c0980391be1986e9f6c4ac9de1b1a90"
|
||||
name = "github.com/aws/aws-lambda-go"
|
||||
packages = [
|
||||
"events",
|
||||
"lambda",
|
||||
"lambda/handlertrace",
|
||||
"lambda/messages",
|
||||
"lambdacontext",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "55dc88be4cdfaaf4bb4d9f65debd8d4310e0a83c"
|
||||
version = "v1.19.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:913aa8374d300095f235fe6762f74a9ca82bf1fb30d4f830540b2a5dd6f993e4"
|
||||
name = "github.com/aws/aws-sdk-go"
|
||||
packages = [
|
||||
"aws",
|
||||
"aws/awserr",
|
||||
"aws/awsutil",
|
||||
"aws/client",
|
||||
"aws/client/metadata",
|
||||
"aws/corehandlers",
|
||||
"aws/credentials",
|
||||
"aws/credentials/ec2rolecreds",
|
||||
"aws/credentials/endpointcreds",
|
||||
"aws/credentials/processcreds",
|
||||
"aws/credentials/stscreds",
|
||||
"aws/csm",
|
||||
"aws/defaults",
|
||||
"aws/ec2metadata",
|
||||
"aws/endpoints",
|
||||
"aws/request",
|
||||
"aws/session",
|
||||
"aws/signer/v4",
|
||||
"internal/context",
|
||||
"internal/ini",
|
||||
"internal/sdkio",
|
||||
"internal/sdkmath",
|
||||
"internal/sdkrand",
|
||||
"internal/sdkuri",
|
||||
"internal/shareddefaults",
|
||||
"internal/strings",
|
||||
"internal/sync/singleflight",
|
||||
"private/protocol",
|
||||
"private/protocol/json/jsonutil",
|
||||
"private/protocol/jsonrpc",
|
||||
"private/protocol/query",
|
||||
"private/protocol/query/queryutil",
|
||||
"private/protocol/rest",
|
||||
"private/protocol/xml/xmlutil",
|
||||
"service/ssm",
|
||||
"service/sts",
|
||||
"service/sts/stsiface",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "2bec4e3ae9cb717c0082a489e75ab9db71c98b23"
|
||||
version = "v1.34.22"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:a67f9275b42e8bb95ba38f705062175ef65538bcdc107e0771763e6cde80c3c3"
|
||||
name = "github.com/go-sql-driver/mysql"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "17ef3dd9d98b69acec3e85878995ada9533a9370"
|
||||
version = "v1.5.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:13fe471d0ed891e8544eddfeeb0471fd3c9f2015609a1c000aefdedf52a19d40"
|
||||
name = "github.com/jmespath/go-jmespath"
|
||||
packages = ["."]
|
||||
pruneopts = ""
|
||||
revision = "c2b33e84"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
input-imports = [
|
||||
"github.com/aws/aws-lambda-go/events",
|
||||
"github.com/aws/aws-lambda-go/lambda",
|
||||
"github.com/aws/aws-sdk-go/aws",
|
||||
"github.com/aws/aws-sdk-go/aws/session",
|
||||
"github.com/aws/aws-sdk-go/service/ssm",
|
||||
"github.com/go-sql-driver/mysql",
|
||||
]
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
25
main-web/serverless/go/src/catherine-fc-api/Gopkg.toml
Normal file
@@ -0,0 +1,25 @@
|
||||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# required = ["github.com/user/thing/cmd/thing"]
|
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project"
|
||||
# version = "1.0.0"
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project2"
|
||||
# branch = "dev"
|
||||
# source = "github.com/myfork/project2"
|
||||
#
|
||||
# [[override]]
|
||||
# name = "github.com/x/y"
|
||||
# version = "2.4.0"
|
||||
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/aws/aws-lambda-go"
|
||||
version = "1.x"
|
||||
12
main-web/serverless/go/src/catherine-fc-api/Makefile
Normal file
@@ -0,0 +1,12 @@
|
||||
.PHONY: build clean deploy
|
||||
|
||||
build:
|
||||
dep ensure -v
|
||||
env GOOS=linux go build -ldflags="-s -w" -o bin/archive archive/main.go
|
||||
env GOOS=linux go build -ldflags="-s -w" -o bin/guide guide/main.go
|
||||
|
||||
clean:
|
||||
rm -rf ./bin ./vendor Gopkg.lock
|
||||
|
||||
deploy: clean build
|
||||
sls deploy --verbose
|
||||
72
main-web/serverless/go/src/catherine-fc-api/archive/main.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
|
||||
"github.com/aws/aws-lambda-go/events"
|
||||
"github.com/aws/aws-lambda-go/lambda"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/ssm"
|
||||
)
|
||||
|
||||
// Response is of type APIGatewayProxyResponse since we're leveraging the
|
||||
// AWS Lambda Proxy Request functionality (default behavior)
|
||||
//
|
||||
// https://serverless.com/framework/docs/providers/aws/events/apigateway/#lambda-proxy-integration
|
||||
type Response events.APIGatewayProxyResponse
|
||||
|
||||
// Handler is our lambda handler invoked by the `lambda.Start` function call
|
||||
func Handler(ctx context.Context) (Response, error) {
|
||||
svc := ssm.New(session.New(), &aws.Config{
|
||||
Region: aws.String("ap-northeast-1"),
|
||||
})
|
||||
res, _ := svc.GetParameter(&ssm.GetParameterInput{
|
||||
Name: aws.String("db-endpoint"),
|
||||
WithDecryption: aws.Bool(true),
|
||||
})
|
||||
dbendpoint := *res.Parameter.Value
|
||||
|
||||
/*
|
||||
res, _ = svc.GetParameter(&ssm.GetParameterInput{
|
||||
Name: aws.String("db-username"),
|
||||
WithDecryption: aws.Bool(true),
|
||||
})
|
||||
dbusername := *res.Parameter.Value
|
||||
res, _ = svc.GetParameter(&ssm.GetParameterInput{
|
||||
Name: aws.String("db-password"),
|
||||
WithDecryption: aws.Bool(true),
|
||||
})
|
||||
dbpassword := *res.Parameter.Value
|
||||
*/
|
||||
var buf bytes.Buffer
|
||||
|
||||
body, err := json.Marshal(map[string]interface{}{
|
||||
"message": "Okay so your other function also executed successfully!",
|
||||
"dbendpoint": dbendpoint,
|
||||
})
|
||||
if err != nil {
|
||||
return Response{StatusCode: 404}, err
|
||||
}
|
||||
json.HTMLEscape(&buf, body)
|
||||
|
||||
resp := Response{
|
||||
StatusCode: 200,
|
||||
IsBase64Encoded: false,
|
||||
Body: buf.String(),
|
||||
Headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
"X-MyCompany-Func-Reply": "world-handler",
|
||||
},
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
lambda.Start(Handler)
|
||||
}
|
||||
45
main-web/serverless/go/src/catherine-fc-api/guide/main.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/aws/aws-lambda-go/events"
|
||||
"github.com/aws/aws-lambda-go/lambda"
|
||||
)
|
||||
|
||||
// Response is of type APIGatewayProxyResponse since we're leveraging the
|
||||
// AWS Lambda Proxy Request functionality (default behavior)
|
||||
//
|
||||
// https://serverless.com/framework/docs/providers/aws/events/apigateway/#lambda-proxy-integration
|
||||
type Response events.APIGatewayProxyResponse
|
||||
|
||||
// Handler is our lambda handler invoked by the `lambda.Start` function call
|
||||
func Handler(ctx context.Context) (Response, error) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
body, err := json.Marshal(map[string]interface{}{
|
||||
"message": "Go Serverless v1.0! Your function executed successfully!",
|
||||
})
|
||||
if err != nil {
|
||||
return Response{StatusCode: 404}, err
|
||||
}
|
||||
json.HTMLEscape(&buf, body)
|
||||
|
||||
resp := Response{
|
||||
StatusCode: 200,
|
||||
IsBase64Encoded: false,
|
||||
Body: buf.String(),
|
||||
Headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
"X-MyCompany-Func-Reply": "hello-handler",
|
||||
},
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
lambda.Start(Handler)
|
||||
}
|
||||
152
main-web/serverless/go/src/catherine-fc-api/serverless.yml
Normal file
@@ -0,0 +1,152 @@
|
||||
# Welcome to Serverless!
|
||||
#
|
||||
# This file is the main config file for your service.
|
||||
# It's very minimal at this point and uses default values.
|
||||
# You can always add more config options for more control.
|
||||
# We've included some commented out config examples here.
|
||||
# Just uncomment any of them to get that config option.
|
||||
#
|
||||
# For full config options, check the docs:
|
||||
# docs.serverless.com
|
||||
#
|
||||
# Happy Coding!
|
||||
|
||||
service: catherine-fc-api
|
||||
# app and org for use with dashboard.serverless.com
|
||||
#app: your-app-name
|
||||
#org: your-org-name
|
||||
custom:
|
||||
VpcId:
|
||||
dev: "vpc-c54553a2"
|
||||
sqa: "vpc-c54553a2"
|
||||
int: "vpc-c54553a2"
|
||||
uat: "vpc-c54553a2"
|
||||
prd: "vpc-c54553a2"
|
||||
Subnet1:
|
||||
dev: "subnet-0d0fdf45"
|
||||
sqa: "subnet-0d0fdf45"
|
||||
int: "subnet-0d0fdf45"
|
||||
uat: "subnet-0d0fdf45"
|
||||
prd: "subnet-0d0fdf45"
|
||||
Subnet2:
|
||||
dev: "subnet-4dcecc16"
|
||||
sqa: "subnet-4dcecc16"
|
||||
int: "subnet-4dcecc16"
|
||||
uat: "subnet-4dcecc16"
|
||||
prd: "subnet-4dcecc16"
|
||||
|
||||
# You can pin your service to only deploy with a specific Serverless version
|
||||
# Check out our docs for more details
|
||||
# frameworkVersion: "=X.X.X"
|
||||
frameworkVersion: '>=1.28.0 <=2.0.0'
|
||||
|
||||
provider:
|
||||
name: aws
|
||||
runtime: go1.x
|
||||
region: ap-northeast-1
|
||||
versionFunctions: false
|
||||
logRetentionInDays: 14
|
||||
memorySize: 128
|
||||
deploymentBucket: catherine-fc-serverless-bucket
|
||||
stage: dev
|
||||
# you can overwrite defaults here
|
||||
# stage: dev
|
||||
# region: us-east-1
|
||||
iamRoleStatements:
|
||||
- Effect: "Allow"
|
||||
Action:
|
||||
- "lambda:InvokeFunction"
|
||||
Resource:
|
||||
- "arn:aws:lambda:*:*:function:*"
|
||||
|
||||
- Effect: "Allow"
|
||||
Action:
|
||||
- "logs:CreateLogGroup"
|
||||
- "logs:CreateLogStream"
|
||||
- "logs:PutLogEvents"
|
||||
Resource:
|
||||
- "arn:aws:logs:*:*:*"
|
||||
|
||||
- Effect: "Allow"
|
||||
Action:
|
||||
- "ssm:GetParameter"
|
||||
Resource:
|
||||
- "arn:aws:ssm:*:*:parameter/*"
|
||||
|
||||
# you can define service wide environment variables here
|
||||
# environment:
|
||||
# variable1: value1
|
||||
|
||||
package:
|
||||
exclude:
|
||||
- ./**
|
||||
include:
|
||||
- ./bin/**
|
||||
|
||||
functions:
|
||||
guideAPI:
|
||||
handler: bin/guide
|
||||
timeout: 3
|
||||
events:
|
||||
- http:
|
||||
path: guide
|
||||
method: get
|
||||
archiveAPI:
|
||||
handler: bin/archive
|
||||
timeout: 3
|
||||
events:
|
||||
- http:
|
||||
path: archive
|
||||
method: get
|
||||
# The following are a few example events you can configure
|
||||
# NOTE: Please make sure to change your handler code to work with those events
|
||||
# Check the event documentation for details
|
||||
# events:
|
||||
# events:
|
||||
# - http:
|
||||
# path: users/create
|
||||
# method: get
|
||||
# - websocket: $connect
|
||||
# - s3: ${env:BUCKET}
|
||||
# - schedule: rate(10 minutes)
|
||||
# - sns: greeter-topic
|
||||
# - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000
|
||||
# - alexaSkill: amzn1.ask.skill.xx-xx-xx-xx
|
||||
# - alexaSmartHome: amzn1.ask.skill.xx-xx-xx-xx
|
||||
# - iot:
|
||||
# sql: "SELECT * FROM 'some_topic'"
|
||||
# - cloudwatchEvent:
|
||||
# event:
|
||||
# source:
|
||||
# - "aws.ec2"
|
||||
# detail-type:
|
||||
# - "EC2 Instance State-change Notification"
|
||||
# detail:
|
||||
# state:
|
||||
# - pending
|
||||
# - cloudwatchLog: '/aws/lambda/hello'
|
||||
# - cognitoUserPool:
|
||||
# pool: MyUserPool
|
||||
# trigger: PreSignUp
|
||||
# - alb:
|
||||
# listenerArn: arn:aws:elasticloadbalancing:us-east-1:XXXXXX:listener/app/my-load-balancer/50dc6c495c0c9188/
|
||||
# priority: 1
|
||||
# conditions:
|
||||
# host: example.com
|
||||
# path: /hello
|
||||
|
||||
# Define function environment variables here
|
||||
# environment:
|
||||
# variable2: value2
|
||||
|
||||
# you can add CloudFormation resource templates here
|
||||
#resources:
|
||||
# Resources:
|
||||
# NewResource:
|
||||
# Type: AWS::S3::Bucket
|
||||
# Properties:
|
||||
# BucketName: my-new-bucket
|
||||
# Outputs:
|
||||
# NewOutput:
|
||||
# Description: "Description for the output"
|
||||
# Value: "Some output value"
|
||||
|
Before Width: | Height: | Size: 3.1 KiB |
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
import React from 'react';
|
||||
import logo from './logo.svg';
|
||||
import './App.css';
|
||||
import RPC from 'discord-rpc';
|
||||
function App(): JSX.Element {
|
||||
let client: any = null;
|
||||
const clientId = '207646673902501888';
|
||||
const scopes = ['rpc', 'rpc.api', 'messages.read'];
|
||||
if (client === null) {
|
||||
client = new RPC.Client({ transport: 'websocket' });
|
||||
if (client) {
|
||||
client.on('ready', () => {
|
||||
if (client) {
|
||||
console.log('Logged in as', client.application.name);
|
||||
console.log('Authed for user', client.user.username);
|
||||
client.selectVoiceChannel('740735736361517137');
|
||||
}
|
||||
});
|
||||
// Log in to RPC with client id
|
||||
client.login({ clientId, scopes });
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<p>
|
||||
Edit <code>src/App.tsx</code> and save to reload.
|
||||
</p>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</a>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -1,7 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
|
||||
<g fill="#61DAFB">
|
||||
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
|
||||
<circle cx="420.9" cy="296.5" r="45.7"/>
|
||||
<path d="M520.5 78.1z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
@@ -4,6 +4,7 @@
|
||||
"private": true,
|
||||
"homepage": "tool",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.24.4",
|
||||
"dotenv": "^8.2.0",
|
||||
"node-sass": "^4.13.1",
|
||||
"react": "^16.13.1",
|
||||
@@ -12,7 +13,7 @@
|
||||
"semantic-ui-css": "^2.4.1",
|
||||
"semantic-ui-react": "^0.88.2",
|
||||
"socket.io-client": "^2.3.0",
|
||||
"typescript": "^3.7.5"
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
|
||||
@@ -1,23 +1,7 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"icons": [],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
|
||||
@@ -37,7 +37,7 @@ function App(): JSX.Element {
|
||||
}
|
||||
});
|
||||
sock.on('login', (data: ILoginMessage) => {
|
||||
console.log(data);
|
||||
console.log('login', data);
|
||||
setCurrentPlayers(data);
|
||||
});
|
||||
sock.on('registerUser', (data: string) => {
|
||||
@@ -68,10 +68,11 @@ function App(): JSX.Element {
|
||||
setSocket(sock);
|
||||
}
|
||||
}
|
||||
const janken = (option: string): void => {
|
||||
const janken = (option: string, room: string): void => {
|
||||
if (socket && currentUser) {
|
||||
const message: IJankenSelect = {
|
||||
userName: currentUser,
|
||||
room,
|
||||
option
|
||||
};
|
||||
socket.emit('janken', message);
|
||||
@@ -82,9 +83,9 @@ function App(): JSX.Element {
|
||||
socket.emit('moveToStage');
|
||||
}
|
||||
};
|
||||
const registerUser = (username: string): void => {
|
||||
const registerUser = (username: string, room: string): void => {
|
||||
if (socket) {
|
||||
socket.emit('registerUser', username);
|
||||
socket.emit('registerUser', { username, room });
|
||||
}
|
||||
};
|
||||
const previousIndex = (): void => {
|
||||
@@ -97,9 +98,9 @@ function App(): JSX.Element {
|
||||
socket.emit('nextIndex');
|
||||
}
|
||||
};
|
||||
const againGame = (): void => {
|
||||
const againGame = (room: string): void => {
|
||||
if (socket) {
|
||||
socket.emit('againGame');
|
||||
socket.emit('againGame', room);
|
||||
}
|
||||
};
|
||||
const exitGame = (): void => {
|
||||
|
||||
@@ -7,15 +7,16 @@ type ComponentProps = {
|
||||
currentUser: string;
|
||||
currentPlayers: ILoginMessage;
|
||||
jankenResults: IJankenResult | null;
|
||||
janken: (option: string) => void;
|
||||
onSubmit: (username: string) => void;
|
||||
janken: (option: string, room: string) => void;
|
||||
onSubmit: (username: string, room: string) => void;
|
||||
moveToStage: () => void;
|
||||
againGame: () => void;
|
||||
againGame: (room: string) => void;
|
||||
};
|
||||
|
||||
export const Janken: FunctionComponent<ComponentProps> = (props): JSX.Element => {
|
||||
const { currentUser, currentPlayers, jankenResults, janken, onSubmit, moveToStage, againGame } = props;
|
||||
const [userName, setUserName] = useState<string>('');
|
||||
const [room, setRoom] = useState<string>('');
|
||||
const getIcon = (result: string): JSX.Element | undefined => {
|
||||
switch (result) {
|
||||
case 'rock':
|
||||
@@ -33,12 +34,13 @@ export const Janken: FunctionComponent<ComponentProps> = (props): JSX.Element =>
|
||||
<Button
|
||||
color='pink'
|
||||
size='large'
|
||||
onClick={againGame}
|
||||
onClick={(): void => againGame(room)}
|
||||
>
|
||||
Again
|
||||
</Button>
|
||||
);
|
||||
} else {
|
||||
/*
|
||||
return (
|
||||
<Button
|
||||
color='pink'
|
||||
@@ -48,6 +50,8 @@ export const Janken: FunctionComponent<ComponentProps> = (props): JSX.Element =>
|
||||
Stages
|
||||
</Button>
|
||||
);
|
||||
*/
|
||||
return (<></>);
|
||||
}
|
||||
}
|
||||
if (currentPlayers.playerOne === '' || currentPlayers.playerTwo === '') {
|
||||
@@ -64,9 +68,18 @@ export const Janken: FunctionComponent<ComponentProps> = (props): JSX.Element =>
|
||||
loading={false}
|
||||
onChange={(e): void => setUserName(e.target.value)}
|
||||
/>
|
||||
<Label>
|
||||
Room Name
|
||||
</Label>
|
||||
<Input
|
||||
value={room}
|
||||
loading={false}
|
||||
onChange={(e): void => setRoom(e.target.value)}
|
||||
/>
|
||||
</Form.Field>
|
||||
<Button
|
||||
onClick={(): void => onSubmit(userName)}
|
||||
disabled={room.trim() === '' || userName.trim() === ''}
|
||||
onClick={(): void => onSubmit(userName, room)}
|
||||
>
|
||||
Login
|
||||
</Button>
|
||||
@@ -87,7 +100,7 @@ export const Janken: FunctionComponent<ComponentProps> = (props): JSX.Element =>
|
||||
<Button
|
||||
color='pink'
|
||||
size='huge'
|
||||
onClick={(): void => janken('rock')}
|
||||
onClick={(): void => janken('rock', room)}
|
||||
>
|
||||
<Icon name='hand rock outline' />
|
||||
</Button>
|
||||
@@ -95,7 +108,7 @@ export const Janken: FunctionComponent<ComponentProps> = (props): JSX.Element =>
|
||||
<Button
|
||||
color='pink'
|
||||
size='huge'
|
||||
onClick={(): void => janken('scissors')}
|
||||
onClick={(): void => janken('scissors', room)}
|
||||
>
|
||||
<Icon name='hand scissors outline' />
|
||||
</Button>
|
||||
@@ -103,7 +116,7 @@ export const Janken: FunctionComponent<ComponentProps> = (props): JSX.Element =>
|
||||
<Button
|
||||
color='pink'
|
||||
size='huge'
|
||||
onClick={(): void => janken('paper')}
|
||||
onClick={(): void => janken('paper', room)}
|
||||
>
|
||||
<Icon name='hand paper outline' />
|
||||
</Button>
|
||||
|
||||
@@ -16,5 +16,6 @@ export interface ILogin {
|
||||
|
||||
export interface IJankenSelect {
|
||||
userName: string;
|
||||
room: string;
|
||||
option: string;
|
||||
}
|
||||
|
||||
23
twitch_chat_reader/twitch-chat/.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
46
twitch_chat_reader/twitch-chat/README.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.\
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `npm test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `npm run build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `npm run eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
50
twitch_chat_reader/twitch-chat/package.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "twitch-chat",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-scripts": "4.0.3",
|
||||
"typescript": "^4.2.4",
|
||||
"web-vitals": "^1.1.1",
|
||||
"socket.io": "^2.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^5.11.10",
|
||||
"@testing-library/react": "^11.2.6",
|
||||
"@testing-library/user-event": "^12.8.3",
|
||||
"@types/jest": "^26.0.22",
|
||||
"@types/node": "^12.20.7",
|
||||
"@types/react": "^17.0.3",
|
||||
"@types/react-dom": "^17.0.3",
|
||||
"@types/socket.io": "^1.4.32",
|
||||
"tslint": "^5.18.0",
|
||||
"tslint-config-airbnb": "^5.11.1",
|
||||
"tslint-react": "^4.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
||||
BIN
twitch_chat_reader/twitch-chat/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
@@ -9,7 +9,6 @@
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
9
twitch_chat_reader/twitch-chat/public/manifest.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
3
twitch_chat_reader/twitch-chat/public/robots.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
||||
38
twitch_chat_reader/twitch-chat/src/App.css
Normal file
@@ -0,0 +1,38 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
9
twitch_chat_reader/twitch-chat/src/App.test.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />);
|
||||
const linkElement = screen.getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
||||
61
twitch_chat_reader/twitch-chat/src/App.tsx
Normal file
@@ -0,0 +1,61 @@
|
||||
import React from 'react';
|
||||
import logo from './logo.svg';
|
||||
import './App.css';
|
||||
|
||||
export const socket = new WebSocket('ws://127.0.0.1:7000', "rust-websocket");
|
||||
socket.addEventListener('open', (event) => {
|
||||
console.log(event);
|
||||
const test = {
|
||||
action: 'test',
|
||||
message: 'unchi'
|
||||
};
|
||||
socket.send(JSON.stringify(test));
|
||||
});
|
||||
socket.addEventListener('message', (event) => {
|
||||
console.log(event);
|
||||
const data = event.data;
|
||||
if (data.indexOf('PING') === 0) {
|
||||
socket.send('PONG');
|
||||
socket.send('PRIVMSG #osoma_crawler :オソマ');
|
||||
}
|
||||
})
|
||||
function App() {
|
||||
/*
|
||||
const socket = new WebSocket('wss://irc-ws.chat.twitch.tv:443');
|
||||
socket.addEventListener('open', (event) => {
|
||||
console.log(event);
|
||||
socket.send('PASS oauth:xweh94y0e330bo1i9rw0ty6fo02m9w');
|
||||
socket.send('NICK osoma_bot');
|
||||
socket.send('JOIN #osoma_crawler');
|
||||
});
|
||||
socket.addEventListener('message', (event) => {
|
||||
console.log(event);
|
||||
const data = event.data;
|
||||
if (data.indexOf('PING') === 0) {
|
||||
socket.send('PONG');
|
||||
socket.send('PRIVMSG #osoma_crawler :オソマ');
|
||||
}
|
||||
})
|
||||
*/
|
||||
console.log("test")
|
||||
return (
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<p>
|
||||
Edit <code>src/App.tsx</code> and save to reload.
|
||||
</p>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</a>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
13
twitch_chat_reader/twitch-chat/src/index.css
Normal file
@@ -0,0 +1,13 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
}
|
||||
17
twitch_chat_reader/twitch-chat/src/index.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
||||
1
twitch_chat_reader/twitch-chat/src/logo.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
1
twitch_chat_reader/twitch-chat/src/react-app-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="react-scripts" />
|
||||
15
twitch_chat_reader/twitch-chat/src/reportWebVitals.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ReportHandler } from 'web-vitals';
|
||||
|
||||
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||
getCLS(onPerfEntry);
|
||||
getFID(onPerfEntry);
|
||||
getFCP(onPerfEntry);
|
||||
getLCP(onPerfEntry);
|
||||
getTTFB(onPerfEntry);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default reportWebVitals;
|
||||
5
twitch_chat_reader/twitch-chat/src/setupTests.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom';
|
||||
26
twitch_chat_reader/twitch-chat/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||