diff --git a/.github/workflows/azure-static-web-apps-black-desert-01c789f03.yml b/.github/workflows/azure-static-web-apps-black-desert-01c789f03.yml new file mode 100644 index 00000000..51f9f123 --- /dev/null +++ b/.github/workflows/azure-static-web-apps-black-desert-01c789f03.yml @@ -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 + - 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_BLACK_DESERT_01C789F03 }} + 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: "/src" # App source code path + # api_location: "api" # Api source code path - optional + skip_api_build: true + output_location: "/src" # 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_BLACK_DESERT_01C789F03 }} + action: "close" diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..036c4083 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "ms-azuretools.vscode-azurefunctions" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..e7be0445 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,12 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Node Functions", + "type": "node", + "request": "attach", + "port": 9229, + "preLaunchTask": "func: host start" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..35a8360f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "azureFunctions.deploySubpath": "api", + "azureFunctions.postDeployTask": "npm install (functions)", + "azureFunctions.projectLanguage": "JavaScript", + "azureFunctions.projectRuntime": "~4", + "debug.internalConsoleOptions": "neverOpen", + "azureFunctions.preDeployTask": "npm prune (functions)" +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..3201931e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,33 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "func", + "label": "func: host start", + "command": "host start", + "problemMatcher": "$func-node-watch", + "isBackground": true, + "dependsOn": "npm install (functions)", + "options": { + "cwd": "${workspaceFolder}/api" + } + }, + { + "type": "shell", + "label": "npm install (functions)", + "command": "npm install", + "options": { + "cwd": "${workspaceFolder}/api" + } + }, + { + "type": "shell", + "label": "npm prune (functions)", + "command": "npm prune --production", + "problemMatcher": [], + "options": { + "cwd": "${workspaceFolder}/api" + } + } + ] +} \ No newline at end of file diff --git a/func_api/.funcignore b/func_api/.funcignore new file mode 100644 index 00000000..d5b3b4a2 --- /dev/null +++ b/func_api/.funcignore @@ -0,0 +1,10 @@ +*.js.map +*.ts +.git* +.vscode +__azurite_db*__.json +__blobstorage__ +__queuestorage__ +local.settings.json +test +tsconfig.json \ No newline at end of file diff --git a/func_api/.gitignore b/func_api/.gitignore new file mode 100644 index 00000000..01774db7 --- /dev/null +++ b/func_api/.gitignore @@ -0,0 +1,99 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TypeScript output +dist +out + +# Azure Functions artifacts +bin +obj +appsettings.json +local.settings.json + +# Azurite artifacts +__blobstorage__ +__queuestorage__ +__azurite_db*__.json \ No newline at end of file diff --git a/func_api/host.json b/func_api/host.json new file mode 100644 index 00000000..fd4bee79 --- /dev/null +++ b/func_api/host.json @@ -0,0 +1,15 @@ +{ + "version": "2.0", + "logging": { + "applicationInsights": { + "samplingSettings": { + "isEnabled": true, + "excludedTypes": "Request" + } + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[3.*, 4.0.0)" + } +} \ No newline at end of file diff --git a/func_api/message/function.json b/func_api/message/function.json new file mode 100644 index 00000000..9f2d4d85 --- /dev/null +++ b/func_api/message/function.json @@ -0,0 +1,19 @@ +{ + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "req", + "methods": [ + "get", + "post" + ] + }, + { + "type": "http", + "direction": "out", + "name": "res" + } + ] +} \ No newline at end of file diff --git a/func_api/message/index.js b/func_api/message/index.js new file mode 100644 index 00000000..cbbabf89 --- /dev/null +++ b/func_api/message/index.js @@ -0,0 +1,5 @@ +module.exports = async function (context, req) { + context.res.json({ + text: "Hello from the API" + }); +}; \ No newline at end of file diff --git a/func_api/message/sample.dat b/func_api/message/sample.dat new file mode 100644 index 00000000..26aac46f --- /dev/null +++ b/func_api/message/sample.dat @@ -0,0 +1,3 @@ +{ + "name": "Azure" +} \ No newline at end of file diff --git a/func_api/package.json b/func_api/package.json new file mode 100644 index 00000000..4342e1b2 --- /dev/null +++ b/func_api/package.json @@ -0,0 +1,11 @@ +{ + "name": "api", + "version": "1.0.0", + "description": "", + "scripts": { + "start": "func start", + "test": "echo \"No tests yet...\"" + }, + "dependencies": {}, + "devDependencies": {} +} \ No newline at end of file diff --git a/src/2.html b/src/2.html new file mode 100644 index 00000000..dcd1ffd8 --- /dev/null +++ b/src/2.html @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="styles.css"> + <title>Vanilla JavaScript App</title> +</head> + +<body> + <main> + <h1>Page 1</h1> + <p>Loading content from the API: <b id="name">...</b></p> + </main> + + <!-- <script> + (async function() { + const { text } = await( await fetch(`/api/message`)).json(); + document.querySelector('#name').textContent = text; + }()); + </script> --> +</body> + +</html> \ No newline at end of file diff --git a/src/index.html b/src/index.html index d5fd5a92..6320b792 100644 --- a/src/index.html +++ b/src/index.html @@ -2,16 +2,24 @@ <html lang="en"> <head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link rel="stylesheet" href="styles.css"> - <title>Vanilla JavaScript App</title> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="styles.css"> + <title>Vanilla JavaScript App</title> </head> <body> - <main> + <main> <h1>Vanilla JavaScript App</h1> - </main> + <p>Loading content from the API: <b id="name">...</b></p> + </main> + + <script> + (async function() { + const { text } = await( await fetch(`/api/message`)).json(); + document.querySelector('#name').textContent = text; + }()); + </script> </body> </html> \ No newline at end of file diff --git a/src/loaderio-032d0fee4b0d62a178afd1b323636a8e.txt b/src/loaderio-032d0fee4b0d62a178afd1b323636a8e.txt new file mode 100644 index 00000000..85fbe415 --- /dev/null +++ b/src/loaderio-032d0fee4b0d62a178afd1b323636a8e.txt @@ -0,0 +1 @@ +loaderio-032d0fee4b0d62a178afd1b323636a8e \ No newline at end of file diff --git a/src/loaderio-9598a6a8c3e7144e7dcc13ee9831752a.txt b/src/loaderio-9598a6a8c3e7144e7dcc13ee9831752a.txt new file mode 100644 index 00000000..f5c25cfa --- /dev/null +++ b/src/loaderio-9598a6a8c3e7144e7dcc13ee9831752a.txt @@ -0,0 +1 @@ +loaderio-9598a6a8c3e7144e7dcc13ee9831752a \ No newline at end of file diff --git a/src/staticwebapp.config.json b/src/staticwebapp.config.json new file mode 100644 index 00000000..f3612eb2 --- /dev/null +++ b/src/staticwebapp.config.json @@ -0,0 +1,62 @@ +{ + "trailingSlash": "auto", + "routes": [ + { + "route": "/.auth/login/aad", + "statusCode": 404 + }, + { + "route": "/.auth/login/apple", + "statusCode": 404 + }, + { + "route": "/.auth/login/facebook", + "statusCode": 404 + }, + { + "route": "/.auth/login/github", + "statusCode": 404 + }, + { + "route": "/.auth/login/google", + "statusCode": 404 + }, + { + "route": "/.auth/login/twitter", + "statusCode": 404 + }, + { + "route": "/login", + "allowedRoles": [ + "anonymous" + ], + "rewrite": "/.auth/login/aadb2c" + }, + { + "route": "/logout", + "redirect": "/.auth/logout" + } + ], + "auth": { + "identityProviders": { + "customOpenIdConnectProviders": { + "aadb2c": { + "registration": { + "clientIdSettingName": "AADB2C_PROVIDER_CLIENT_ID", + "clientCredential": { + "clientSecretSettingName": "AADB2C_PROVIDER_CLIENT_SECRET" + }, + "openIdConnectConfiguration": { + "wellKnownOpenIdConfiguration": "https://itcssob2cdev.b2clogin.com/itcssob2cdev.onmicrosoft.com/B2C_1A_ITC_SUSI_SOCIAL/v2.0/.well-known/openid-configuration" + } + }, + "login": { + "nameClaimType": "email", + "scopes": [], + "loginParameterNames": [] + } + } + } + } + } +} \ No newline at end of file