├── .github ├── auto-merge.yml ├── dependabot.yml └── workflows │ ├── auto-merge.yml │ ├── integration-tester.yml │ ├── integration-tests │ ├── generated │ │ ├── basic-sandbox-test.js │ │ ├── basic-staging-test.js │ │ ├── runtime-config.json │ │ └── tests-config.json │ └── scripts │ │ ├── get-app-name.js │ │ ├── get-stack-name.js │ │ └── get-staging-url.js │ └── rc-tester.yml ├── .gitignore ├── .npmrc ├── app.arc ├── package.json ├── public └── index.html ├── readme.md └── src └── http ├── get-login ├── github.js └── index.js ├── post-graphql ├── index.js ├── middleware │ ├── auth.js │ └── query.js ├── resolvers.js └── schema.graphql └── post-logout └── index.js /.github/auto-merge.yml: -------------------------------------------------------------------------------- 1 | #- match: 2 | # dependency_name: aws-sdk 3 | # update_type: semver:minor 4 | 5 | - match: 6 | dependency_type: development 7 | update_type: semver:major 8 | 9 | - match: 10 | dependency_type: production 11 | update_type: security:minor # includes patch updates! 12 | 13 | - match: 14 | dependency_type: production 15 | update_type: semver:minor 16 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 99 8 | -------------------------------------------------------------------------------- /.github/workflows/auto-merge.yml: -------------------------------------------------------------------------------- 1 | name: auto-merge 2 | 3 | on: 4 | pull_request_target: 5 | 6 | jobs: 7 | auto-merge: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: ahmadnassri/action-dependabot-auto-merge@v2 12 | with: 13 | target: minor 14 | github-token: ${{ secrets.BX_GITHUB_PAT }} 15 | -------------------------------------------------------------------------------- /.github/workflows/integration-tester.yml: -------------------------------------------------------------------------------- 1 | name: Integration Tester 2 | # This workflow is automatically synchronized to this file from the integration tester repository. Any local changes will be overwritten. 3 | 4 | on: 5 | push: 6 | pull_request: 7 | schedule: 8 | - cron: "0 9 * * 0-6" 9 | workflow_dispatch: 10 | 11 | jobs: 12 | cancel_if_duplicate: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Cancel Previous Runs 16 | uses: styfle/cancel-workflow-action@0.9.0 17 | with: 18 | access_token: ${{ github.token }} 19 | 20 | sandbox_tests_exist: 21 | timeout-minutes: 10 22 | runs-on: ubuntu-latest 23 | needs: cancel_if_duplicate 24 | steps: 25 | - name: Check out repo 26 | uses: actions/checkout@v2 27 | 28 | - name: Read Test Config 29 | run: echo "TEST_CONFIG_RUN=$(cat .github/workflows/integration-tests/generated/tests-config.json | jq '.run')" >> $GITHUB_ENV 30 | 31 | #fails if no custom tests present 32 | - name: check for custom tests if no sync tests added 33 | if: ${{env.TEST_CONFIG_RUN=='none'}} 34 | run: test -f .github/workflows/integration-tests/custom/**sandbox-test.js || exit 1 35 | 36 | - name: Notify 37 | uses: homoluctus/slatify@master 38 | if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && failure() 39 | with: 40 | type: ${{ job.status }} 41 | job_name: "*No Sandbox Tests Found*" 42 | url: ${{ secrets.BX_SLACK_BX_CHANNEL }} 43 | commit: true 44 | token: ${{ secrets.GITHUB_TOKEN }} 45 | 46 | staging_tests_exist: 47 | timeout-minutes: 10 48 | runs-on: ubuntu-latest 49 | needs: cancel_if_duplicate 50 | steps: 51 | - name: Check out repo 52 | uses: actions/checkout@v2 53 | 54 | - name: Read Test Config 55 | run: echo "TEST_CONFIG_RUN=$(cat .github/workflows/integration-tests/generated/tests-config.json | jq '.run')" >> $GITHUB_ENV 56 | 57 | #fails if no custom tests present 58 | - name: check for custom tests if no sync tests added 59 | if: ${{env.TEST_CONFIG_RUN=='none'}} 60 | run: test -f .github/workflows/integration-tests/custom/**staging-test.js || exit 1 61 | 62 | - name: Notify 63 | uses: homoluctus/slatify@master 64 | if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && failure() 65 | with: 66 | type: ${{ job.status }} 67 | job_name: "*No Staging Tests Found*" 68 | url: ${{ secrets.BX_SLACK_BX_CHANNEL }} 69 | commit: true 70 | token: ${{ secrets.GITHUB_TOKEN }} 71 | 72 | sandbox_tests: 73 | timeout-minutes: 30 74 | needs: sandbox_tests_exist 75 | runs-on: ubuntu-latest 76 | env: 77 | #below sets default to true and will confirm later in workflow 78 | HAS_CUSTOM_TESTS: true 79 | strategy: 80 | matrix: 81 | node-version: [14.x] 82 | os: [windows-latest, ubuntu-latest, macOS-latest] 83 | steps: 84 | - name: Check out repo 85 | uses: actions/checkout@v2 86 | 87 | - name: Set up Node.js 88 | uses: actions/setup-node@v1 89 | with: 90 | node-version: ${{ matrix.node-version }} 91 | 92 | - name: Env 93 | run: | 94 | echo "Event name: ${{ github.event_name }}" 95 | echo "Git ref: ${{ github.ref }}" 96 | echo "GH actor: ${{ github.actor }}" 97 | echo "SHA: ${{ github.sha }}" 98 | VER=`node --version`; echo "Node ver: $VER" 99 | VER=`npm --version`; echo "npm ver: $VER" 100 | 101 | - name: Look for needed runtimes 102 | run: echo "CONFIG_RUNTIMES=$(cat .github/workflows/integration-tests/generated/runtime-config.json | jq '.runtime')" >> $GITHUB_ENV 103 | 104 | - name: Add Deno if needed 105 | #TODO: double quotes should be fixed in the check for this variable. 106 | if: ${{env.CONFIG_RUNTIMES == '"deno"'}} 107 | uses: denoland/setup-deno@main 108 | with: 109 | deno-version: v1.x 110 | 111 | - name: Install 112 | run: npm install 113 | 114 | - name: Install Architect 115 | run: npm i @architect/architect 116 | 117 | - name: Install Test Dependencies 118 | run: npm i tape tap-spec tiny-json-http 119 | 120 | - name: Build if needed 121 | run: npm run build --if-present 122 | 123 | - name: Read Test Config 124 | run: echo "TEST_CONFIG_RUN=$(cat .github/workflows/integration-tests/generated/tests-config.json | jq '.run')" >> $GITHUB_ENV 125 | 126 | - name: Check for custom tests 127 | run: test -f .github/workflows/integration-tests/custom/**sandbox-test.js || echo "HAS_CUSTOM_TESTS=false" >> $GITHUB_ENV 128 | 129 | - name: Run Custom Sandbox Tests 130 | if: ${{env.HAS_CUSTOM_TESTS == true}} 131 | run: QUIET=1 npx tape .github/workflows/integration-tests/custom/**sandbox-test.js | npx tap-spec 132 | 133 | - name: Run Basic Tests 134 | #TODO: double quotes should be fixed in the check for this variable. 135 | if: ${{env.TEST_CONFIG_RUN == '"basic"'}} 136 | run: QUIET=1 npx tape .github/workflows/integration-tests/generated/**sandbox-test.js | npx tap-spec 137 | 138 | - name: Notify 139 | uses: homoluctus/slatify@master 140 | if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && failure() 141 | with: 142 | type: ${{ job.status }} 143 | job_name: "*Sandbox Integration Tests*" 144 | url: ${{ secrets.BX_SLACK_BX_CHANNEL }} 145 | commit: true 146 | token: ${{ secrets.GITHUB_TOKEN }} 147 | 148 | check_user_permission: 149 | outputs: 150 | has-permission: ${{ steps.check.outputs.has-permission }} 151 | runs-on: ubuntu-latest 152 | name: A job to check user's permission level 153 | steps: 154 | # Check for write permission 155 | - name: Check user permission 156 | id: check 157 | uses: scherermichael-oss/action-has-permission@master 158 | with: 159 | required-permission: write 160 | env: 161 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 162 | # Use the output from the `check` step 163 | - name: Run only if user has sufficient permissions 164 | if: steps.check.outputs.has-permission 165 | run: echo "HAS_PERMISSION=true" 166 | - name: Run only if user has NOT sufficient permissions 167 | if: "! steps.check.outputs.has-permission" 168 | run: echo "HAS_PERMISSION=false" 169 | 170 | 171 | 172 | staging_tests: 173 | timeout-minutes: 30 174 | if: needs.check_user_permission.outputs.has-permission 175 | runs-on: ubuntu-latest 176 | env: 177 | #below sets default to true and will confirm later in workflow 178 | HAS_CUSTOM_TESTS: true 179 | needs: [staging_tests_exist, sandbox_tests, check_user_permission] 180 | 181 | strategy: 182 | matrix: 183 | node-version: [14.x] 184 | 185 | steps: 186 | 187 | - name: Check out repo 188 | uses: actions/checkout@v2 189 | 190 | - name: Set up Node.js 191 | uses: actions/setup-node@v1 192 | with: 193 | node-version: ${{ matrix.node-version }} 194 | 195 | - name: Env 196 | run: | 197 | echo "Event name: ${{ github.event_name }}" 198 | echo "Git ref: ${{ github.ref }}" 199 | echo "GH actor: ${{ github.actor }}" 200 | echo "SHA: ${{ github.sha }}" 201 | VER=`node --version`; echo "Node ver: $VER" 202 | VER=`npm --version`; echo "npm ver: $VER" 203 | 204 | - name: Configure AWS credentials from Test account 205 | uses: aws-actions/configure-aws-credentials@v1 206 | with: 207 | aws-access-key-id: ${{ secrets.BX_AWS_ACCESS_KEY_ID }} 208 | aws-secret-access-key: ${{ secrets.BX_AWS_SECRET_ACCESS_KEY }} 209 | aws-region: us-east-1 210 | 211 | - name: Install 212 | run: npm install 213 | 214 | - name: Install Architect 215 | run: npm i @architect/architect 216 | 217 | - name: Build if needed 218 | run: npm run build --if-present 219 | 220 | - name: Install Test Dependencies 221 | run: npm i tape tap-spec tiny-json-http 222 | 223 | - name: Install Script Dependencies 224 | run: npm i yargs 225 | 226 | - name: Set Stack Name 227 | run: echo "UNIQUE_STACK=b${GITHUB_SHA::7}$(date +%d)" >> $GITHUB_ENV 228 | 229 | - name: Find App Name 230 | run: echo "APP_NAME=$(node .github/workflows/integration-tests/scripts/get-app-name.js )" >> $GITHUB_ENV 231 | 232 | - name: Calculate Stack Name 233 | run: echo "AWS_STACK_NAME=$(node .github/workflows/integration-tests/scripts/get-stack-name.js --app-name ${{env.APP_NAME}} --unique-stack ${{env.UNIQUE_STACK}})" >> $GITHUB_ENV 234 | 235 | - name: Deploy Staging 236 | run: npx arc deploy --name ${{env.UNIQUE_STACK}} 237 | 238 | - name: Find Stack Url 239 | run: echo "STAGING_URL=$(aws cloudformation describe-stacks --stack-name ${{env.AWS_STACK_NAME}} | node .github/workflows/integration-tests/scripts/get-staging-url.js)" >> $GITHUB_ENV 240 | 241 | - name: Read Test Config 242 | run: echo "TEST_CONFIG_RUN=$(cat .github/workflows/integration-tests/generated/tests-config.json | jq '.run')" >> $GITHUB_ENV 243 | 244 | - name: Run Basic Tests 245 | if: ${{env.TEST_CONFIG_RUN == '"basic"'}} 246 | run: QUIET=1 STAGING_URL=${{ env.STAGING_URL }} npx tape .github/workflows/integration-tests/generated/**staging-test.js | npx tap-spec 247 | 248 | - name: Check for custom tests 249 | run: test -f .github/workflows/integration-tests/custom/**sandbox-test.js || echo "HAS_CUSTOM_TESTS=false" >> $GITHUB_ENV 250 | 251 | - name: Run Custom Staging Tests 252 | if: ${{env.HAS_CUSTOM_TESTS == true}} 253 | run: QUIET=1 STAGING_URL=${{ env.STAGING_URL }} npx tape .github/workflows/integration-tests/custom/**staging-test.js | npx tap-spec 254 | 255 | - name: Destroy Infrastructure 256 | if: ${{ always() }} 257 | run: npx arc destroy --app ${{ env.APP_NAME }} --name ${{env.UNIQUE_STACK}} --force --now 258 | 259 | # - name: Delete Stack if Destroy Failed 260 | # if: ${{ always() }} 261 | # run: aws cloudformation delete-stack --stack-name ${{env.AWS_STACK_NAME}} 262 | 263 | - name: Notify 264 | uses: homoluctus/slatify@master 265 | if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && failure() 266 | with: 267 | type: ${{ job.status }} 268 | job_name: "*Staging Integration Tests*" 269 | url: ${{ secrets.BX_SLACK_BX_CHANNEL }} 270 | commit: true 271 | token: ${{ secrets.GITHUB_TOKEN }} 272 | -------------------------------------------------------------------------------- /.github/workflows/integration-tests/generated/basic-sandbox-test.js: -------------------------------------------------------------------------------- 1 | const tiny = require('tiny-json-http') 2 | // eslint-disable-next-line import/no-unresolved 3 | const test = require('tape') 4 | // eslint-disable-next-line import/no-unresolved 5 | const sandbox = require('@architect/sandbox') 6 | 7 | const baseUrl = 'http://localhost:3333' 8 | 9 | // this starts a sandbox environment for the tests to execute in. 10 | test('start', async (t) => { 11 | t.plan(1) 12 | await sandbox.start() 13 | t.ok(true, 'started') 14 | }) 15 | 16 | test('Request to Root', async (t) => { 17 | t.plan(1) 18 | try { 19 | const result = await tiny.get({ url: baseUrl }) 20 | t.ok(result.body, 'request to root responded') 21 | } 22 | catch (e) { 23 | t.fail('request to root failed') 24 | } 25 | }) 26 | 27 | // this ends sandbox 28 | test('end', async (t) => { 29 | t.plan(1) 30 | await sandbox.end() 31 | t.ok(true, 'ended') 32 | }) 33 | -------------------------------------------------------------------------------- /.github/workflows/integration-tests/generated/basic-staging-test.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line import/no-unresolved 2 | const tiny = require('tiny-json-http') 3 | // eslint-disable-next-line import/no-unresolved 4 | const test = require('tape') 5 | 6 | const baseUrl = process.env.STAGING_URL 7 | 8 | test('Request Root', async (t) => { 9 | t.plan(1) 10 | try { 11 | const result = await tiny.get({ url: baseUrl }) 12 | t.ok(result.body, 'request to root responded') 13 | } 14 | catch (e) { 15 | t.fail('request to root failed') 16 | } 17 | }) 18 | -------------------------------------------------------------------------------- /.github/workflows/integration-tests/generated/runtime-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtime": "node-only" 3 | } -------------------------------------------------------------------------------- /.github/workflows/integration-tests/generated/tests-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "run": "basic" 3 | } -------------------------------------------------------------------------------- /.github/workflows/integration-tests/scripts/get-app-name.js: -------------------------------------------------------------------------------- 1 | const inventory = require('@architect/inventory') 2 | 3 | inventory({}).then(inv => process.stdout.write(inv.get.app())) 4 | -------------------------------------------------------------------------------- /.github/workflows/integration-tests/scripts/get-stack-name.js: -------------------------------------------------------------------------------- 1 | const argv = require('yargs/yargs')(process.argv.slice(2)) 2 | .demandOption([ 'a', 'u' ]) 3 | .alias('a', 'app-name') 4 | .alias('u', 'unique-stack') 5 | .argv 6 | 7 | 8 | function toPascalCase (text) { 9 | return text.replace(/(^\w|-\w)/g, clearAndUpper) 10 | } 11 | 12 | function clearAndUpper (text) { 13 | return text.replace(/-/, '').toUpperCase() 14 | } 15 | 16 | const fullStackName = toPascalCase([ argv.a, 'staging', argv.u ].join('-')) 17 | 18 | 19 | process.stdout.write(fullStackName) 20 | -------------------------------------------------------------------------------- /.github/workflows/integration-tests/scripts/get-staging-url.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | // Read from stdin 3 | const stackInfoFile = fs.readFileSync(0, 'utf-8') 4 | 5 | const stackInfo = JSON.parse(stackInfoFile) 6 | 7 | const outputs = stackInfo.Stacks[0].Outputs 8 | 9 | 10 | let url = outputs.filter(out => out.OutputKey === 'API')[0]?.OutputValue 11 | 12 | if (!url) { 13 | url = outputs.filter(out => out.OutputKey === 'BucketURL')[0].OutputValue 14 | } 15 | 16 | if (!url) { 17 | throw new Error('App name not found') 18 | } 19 | else { 20 | process.stdout.write(url) 21 | } 22 | -------------------------------------------------------------------------------- /.github/workflows/rc-tester.yml: -------------------------------------------------------------------------------- 1 | name: RC Integration Tester 2 | # This workflow is automatically synchronized to this file from the integration tester repository. Any local changes will be overwritten. 3 | 4 | on: 5 | schedule: 6 | - cron: "30 14 9 FEB *" 7 | workflow_dispatch: 8 | 9 | jobs: 10 | cancel_if_duplicate: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Cancel Previous Runs 14 | uses: styfle/cancel-workflow-action@0.9.0 15 | with: 16 | access_token: ${{ github.token }} 17 | 18 | sandbox_tests_exist: 19 | timeout-minutes: 10 20 | runs-on: ubuntu-latest 21 | needs: cancel_if_duplicate 22 | steps: 23 | - name: Check out repo 24 | uses: actions/checkout@v2 25 | 26 | - name: Read Test Config 27 | run: echo "TEST_CONFIG_RUN=$(cat .github/workflows/integration-tests/generated/tests-config.json | jq '.run')" >> $GITHUB_ENV 28 | 29 | #fails if no custom tests present 30 | - name: check for custom tests if no sync tests added 31 | if: ${{env.TEST_CONFIG_RUN=='none'}} 32 | run: test -f .github/workflows/integration-tests/custom/**sandbox-test.js || exit 1 33 | 34 | - name: Notify 35 | uses: homoluctus/slatify@master 36 | if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && failure() 37 | with: 38 | type: ${{ job.status }} 39 | job_name: "*No Sandbox Tests Found*" 40 | url: ${{ secrets.BX_SLACK_BX_CHANNEL }} 41 | commit: true 42 | token: ${{ secrets.GITHUB_TOKEN }} 43 | 44 | staging_tests_exist: 45 | timeout-minutes: 10 46 | runs-on: ubuntu-latest 47 | needs: cancel_if_duplicate 48 | steps: 49 | - name: Check out repo 50 | uses: actions/checkout@v2 51 | 52 | - name: Read Test Config 53 | run: echo "TEST_CONFIG_RUN=$(cat .github/workflows/integration-tests/generated/tests-config.json | jq '.run')" >> $GITHUB_ENV 54 | 55 | #fails if no custom tests present 56 | - name: check for custom tests if no sync tests added 57 | if: ${{env.TEST_CONFIG_RUN=='none'}} 58 | run: test -f .github/workflows/integration-tests/custom/**staging-test.js || exit 1 59 | 60 | - name: Notify 61 | uses: homoluctus/slatify@master 62 | if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && failure() 63 | with: 64 | type: ${{ job.status }} 65 | job_name: "*No Staging Tests Found*" 66 | url: ${{ secrets.BX_SLACK_BX_CHANNEL }} 67 | commit: true 68 | token: ${{ secrets.GITHUB_TOKEN }} 69 | 70 | sandbox_tests: 71 | timeout-minutes: 30 72 | needs: sandbox_tests_exist 73 | runs-on: ubuntu-latest 74 | env: 75 | #below sets default to true and will confirm later in workflow 76 | HAS_CUSTOM_TESTS: true 77 | strategy: 78 | matrix: 79 | node-version: [12.x, 14.x] 80 | os: [windows-latest, ubuntu-latest, macOS-latest] 81 | steps: 82 | - name: Check out repo 83 | uses: actions/checkout@v2 84 | 85 | - name: Set up Node.js 86 | uses: actions/setup-node@v1 87 | with: 88 | node-version: ${{ matrix.node-version }} 89 | 90 | - name: Env 91 | run: | 92 | echo "Event name: ${{ github.event_name }}" 93 | echo "Git ref: ${{ github.ref }}" 94 | echo "GH actor: ${{ github.actor }}" 95 | echo "SHA: ${{ github.sha }}" 96 | VER=`node --version`; echo "Node ver: $VER" 97 | VER=`npm --version`; echo "npm ver: $VER" 98 | 99 | - name: Look for needed runtimes 100 | run: echo "CONFIG_RUNTIMES=$(cat .github/workflows/integration-tests/generated/runtime-config.json | jq '.runtimes')" >> $GITHUB_ENV 101 | 102 | - name: Add Deno if needed 103 | if: ${{env.CONFIG_RUNTIMES == 'deno'}} 104 | uses: denoland/setup-deno@main 105 | with: 106 | deno-version: v1.x 107 | 108 | - name: Install 109 | run: npm install 110 | 111 | - name: Install Architect 112 | run: npm i @architect/architect@RC 113 | 114 | #- name: Install Sandbox RC 115 | # run: npm i @architect/sandbox 116 | 117 | - name: Install Test Dependencies 118 | run: npm i tape tap-spec tiny-json-http 119 | 120 | - name: Build if needed 121 | run: npm run build --if-present 122 | 123 | - name: Read Test Config 124 | run: echo "TEST_CONFIG_RUN=$(cat .github/workflows/integration-tests/generated/tests-config.json | jq '.run')" >> $GITHUB_ENV 125 | 126 | - name: Check for custom tests 127 | run: test -f .github/workflows/integration-tests/custom/**sandbox-test.js || echo "HAS_CUSTOM_TESTS=false" >> $GITHUB_ENV 128 | 129 | - name: Run Custom Sandbox Tests 130 | if: ${{env.HAS_CUSTOM_TESTS == true}} 131 | run: QUIET=1 npx tape .github/workflows/integration-tests/custom/**sandbox-test.js | npx tap-spec 132 | 133 | #fails if no custom tests present 134 | - name: Run Basic Tests 135 | if: ${{env.TEST_CONFIG_RUN == 'basic'}} 136 | run: QUIET=1 npx tape .github/workflows/integration-tests/generated/**sandbox-test.js | npx tap-spec 137 | 138 | - name: Notify 139 | uses: homoluctus/slatify@master 140 | if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && failure() 141 | with: 142 | type: ${{ job.status }} 143 | job_name: "*Sandbox Integration Tests*" 144 | url: ${{ secrets.BX_SLACK_BX_CHANNEL }} 145 | commit: true 146 | token: ${{ secrets.GITHUB_TOKEN }} 147 | 148 | # check_user_permission: 149 | # outputs: 150 | # has-permission: ${{ steps.check.outputs.has-permission }} 151 | # runs-on: ubuntu-latest 152 | # name: A job to check user's permission level 153 | # steps: 154 | # # Check for write permission 155 | # - name: Check user permission 156 | # id: check 157 | # uses: scherermichael-oss/action-has-permission@master 158 | # with: 159 | # required-permission: write 160 | # env: 161 | # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 162 | # # Use the output from the `check` step 163 | # - name: Run only if user has sufficient permissions 164 | # if: steps.check.outputs.has-permission 165 | # run: echo "HAS_PERMISSION=true" 166 | # - name: Run only if user has NOT sufficient permissions 167 | # if: "! steps.check.outputs.has-permission" 168 | # run: echo "HAS_PERMISSION=false" 169 | 170 | #staging_tests: 171 | # timeout-minutes: 30 172 | # if: needs.check_user_permission.outputs.has-permission 173 | # runs-on: ubuntu-latest 174 | # env: 175 | # #below sets default to true and will confirm later in workflow 176 | # HAS_CUSTOM_TESTS: true 177 | # needs: [staging_tests_exist, sandbox_tests, check_user_permission] 178 | 179 | # strategy: 180 | # matrix: 181 | # node-version: [14.x] 182 | 183 | # steps: 184 | 185 | # - name: Check out repo 186 | # uses: actions/checkout@v2 187 | 188 | # - name: Set up Node.js 189 | # uses: actions/setup-node@v1 190 | # with: 191 | # node-version: ${{ matrix.node-version }} 192 | 193 | # - name: Env 194 | # run: | 195 | # echo "Event name: ${{ github.event_name }}" 196 | # echo "Git ref: ${{ github.ref }}" 197 | # echo "GH actor: ${{ github.actor }}" 198 | # echo "SHA: ${{ github.sha }}" 199 | # VER=`node --version`; echo "Node ver: $VER" 200 | # VER=`npm --version`; echo "npm ver: $VER" 201 | 202 | # - name: Configure AWS credentials from Test account 203 | # uses: aws-actions/configure-aws-credentials@v1 204 | # with: 205 | # aws-access-key-id: ${{ secrets.BX_AWS_ACCESS_KEY_ID }} 206 | # aws-secret-access-key: ${{ secrets.BX_AWS_SECRET_ACCESS_KEY }} 207 | # aws-region: us-east-1 208 | 209 | # - name: Install 210 | # run: npm install 211 | 212 | # - name: Install Architect 213 | # run: npm i @architect/architect 214 | 215 | # - name: Build if needed 216 | # run: npm run build --if-present 217 | 218 | # - name: Install Test Dependencies 219 | # run: npm i tape tap-spec tiny-json-http 220 | 221 | # - name: Install Script Dependencies 222 | # run: npm i yargs 223 | 224 | # - name: Set Stack Name 225 | # run: echo "UNIQUE_STACK=b${GITHUB_SHA::7}$(date +%d)" >> $GITHUB_ENV 226 | 227 | # - name: Find App Name 228 | # run: echo "APP_NAME=$(node .github/workflows/integration-tests/scripts/get-app-name.js )" >> $GITHUB_ENV 229 | 230 | # - name: Calculate Stack Name 231 | # run: echo "AWS_STACK_NAME=$(node .github/workflows/integration-tests/scripts/get-stack-name.js --app-name ${{env.APP_NAME}} --unique-stack ${{env.UNIQUE_STACK}})" >> $GITHUB_ENV 232 | 233 | # - name: Deploy Staging 234 | # run: npx arc deploy --name ${{env.UNIQUE_STACK}} 235 | 236 | # - name: Find Stack Url 237 | # run: echo "STAGING_URL=$(aws cloudformation describe-stacks --stack-name ${{env.AWS_STACK_NAME}} | node .github/workflows/integration-tests/scripts/get-staging-url.js)" >> $GITHUB_ENV 238 | 239 | # - name: Read Test Config 240 | # run: echo "TEST_CONFIG_RUN=$(cat .github/workflows/integration-tests/generated/tests-config.json | jq '.run')" >> $GITHUB_ENV 241 | 242 | # - name: Run Basic Tests 243 | # if: ${{env.TEST_CONFIG_RUN == 'basic'}} 244 | # run: QUIET=1 STAGING_URL=${{ env.STAGING_URL }} npx tape .github/workflows/integration-tests/generated/**staging-test.js | npx tap-spec 245 | 246 | # - name: Check for custom tests 247 | # run: test -f .github/workflows/integration-tests/custom/**sandbox-test.js || echo "HAS_CUSTOM_TESTS=false" >> $GITHUB_ENV 248 | 249 | # - name: Run Custom Staging Tests 250 | # if: ${{env.HAS_CUSTOM_TESTS == true}} 251 | # run: QUIET=1 STAGING_URL=${{ env.STAGING_URL }} npx tape .github/workflows/integration-tests/custom/**staging-test.js | npx tap-spec 252 | 253 | # - name: Destroy Infrastructure 254 | # if: ${{ always() }} 255 | # run: npx arc destroy --app ${{ env.APP_NAME }} --name ${{env.UNIQUE_STACK}} --force --now 256 | 257 | # # - name: Delete Stack if Destroy Failed 258 | # # if: ${{ always() }} 259 | # # run: aws cloudformation delete-stack --stack-name ${{env.AWS_STACK_NAME}} 260 | 261 | # - name: Notify 262 | # uses: homoluctus/slatify@master 263 | # if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && failure() 264 | # with: 265 | # type: ${{ job.status }} 266 | # job_name: "*Staging Integration Tests*" 267 | # url: ${{ secrets.BX_SLACK_WEBHOOK }} 268 | # commit: true 269 | # token: ${{ secrets.GITHUB_TOKEN }} 270 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | package-lock.json 2 | node_modules 3 | *.log 4 | .DS_Store 5 | .arc-env 6 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /app.arc: -------------------------------------------------------------------------------- 1 | @app 2 | graphql-example 3 | 4 | @static 5 | folder public 6 | 7 | @http 8 | get /login 9 | post /graphql 10 | post /logout 11 | 12 | @tables 13 | data 14 | scopeID *String 15 | dataID **String 16 | ttl TTL 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "learn-node-graphql", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "start": "sandbox" 6 | }, 7 | "dependencies": { 8 | "@architect/functions": "^4.0.0", 9 | "@architect/sandbox": "latest", 10 | "@begin/data": "^3.0.0", 11 | "graphql": "^15.5.2", 12 | "graphql-tools": "^8.2.0", 13 | "npm-run-all": "^4.1.5", 14 | "tiny-json-http": "^7.3.0", 15 | "xss": "^1.0.9" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |