Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Aplank14/things
Browse files Browse the repository at this point in the history
  • Loading branch information
samanthathompson52 committed Dec 12, 2023
2 parents ed998c8 + 26268f5 commit 528caba
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 67 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/azure-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Node.js app to Azure Web App - things-strings
name: Azure Deploy Server

on:
push:
branches:
- main
workflow_dispatch:

jobs:
Expand All @@ -23,13 +20,12 @@ jobs:

- name: npm install, build, and test
run: |
cd client
npm i
cd server
npm ci
npm run build
cd ..
- name: Zip artifact for deployment
run: zip release.zip ./client/build/* -r
run: zip release.zip ./server/build/* -r

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Azure Static Web Apps CI/CD

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_MEADOW_0FD7B330F }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/client/" # App source code path
api_location: "" # Api source code path - optional
output_location: "build" # Built app content directory - optional
###### End of Repository/Build Configurations ######

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_MEADOW_0FD7B330F }}
action: "close"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*/build/*

# Logs
logs
*.log
Expand Down
16 changes: 0 additions & 16 deletions client/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions package-lock.json

This file was deleted.

16 changes: 8 additions & 8 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
"name": "things",
"version": "1.0.0",
"description": "",
"main": "server.js",
"main": "server.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "npx ts-node server.ts",
"build": "npx tsc server.ts"
"start": "npx ts-node ./src/server.ts",
"build": "npx tsc"
},
"author": "Andy Plank",
"license": "MIT",
Expand All @@ -23,10 +22,10 @@
"devDependencies": {
"@types/cors": "^2.8.15",
"@types/express": "^4.17.20",
"@types/node": "^20.8.10",
"@types/node": "^20.10.4",
"@types/uuid": "^9.0.6",
"@types/ws": "^8.5.8",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
"typescript": "^5.3.3"
}
}
10 changes: 5 additions & 5 deletions server/server.ts → server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const server = http.createServer(app);
const wsServer = new WebSocketServer({ server });

// Serve the React app
app.use(express.static(path.join(__dirname, '../client/build')));
// app.use(express.static(path.join(__dirname, './client/build')));

// Handle all other routes
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, '../client/build', 'index.html'));
});
// // Handle all other routes
// app.get('*', (req, res) => {
// res.sendFile(path.join(__dirname, '../client/build', 'index.html'));
// });

// app.use(express.static(path.join(__dirname, "./client/build", "index.html")));
// app.use(express.static("public"));
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion server/util.ts → server/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function createPlayer(name: string, userId: string){
}

function createRoom(data: any, userId: any) {
if (data.name === undefined || data.name === "") { return }
const host = createPlayer(data.name, userId);
const code = data.room_code ? data.room_code : generateRandomString(6);
if (getRoom(code) !== null) { return }
Expand All @@ -84,7 +85,7 @@ function createRoom(data: any, userId: any) {
}

function joinRoom(data: any, userId: any) {
if (data.name === undefined || data.room_code === undefined, data.name === "") { return }
if (data.name === undefined || data.room_code === undefined || data.name === "") { return }
const player = createPlayer(data.name, userId);
const room = getRoom(data.room_code);
if (room === null || room.roundNumber !== -1) { return }
Expand Down
28 changes: 11 additions & 17 deletions server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
{
"compilerOptions": {
"moduleResolution": "node",
"target": "es6",
"module": "commonjs",
"lib": ["esnext"],
"strict": true,
"sourceMap": true,
"declaration": true,
"target": "es5",
"module": "commonjs",
"lib": ["es6"],
"allowJs": true,
"outDir": "build",
"rootDir": "src",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declarationDir": "./dist",
"outDir": "./dist",
"typeRoots": ["node_modules/@types"]
},
"include": ["src/**/*.ts"],
"exclude": ["node_modues"]
}
"resolveJsonModule": true
}
}

0 comments on commit 528caba

Please sign in to comment.