From 41798682b055f358ba1ce8adb937cacc25a1aeaf Mon Sep 17 00:00:00 2001 From: Kurt Hutten Date: Sun, 21 Nov 2021 09:05:30 +1100 Subject: [PATCH] Tweaks --- app/api/package.json | 3 +- app/api/src/functions/graphql.ts | 4 +++ app/serverless.yml | 47 +++++++++++++++++++------------- app/yarn.lock | 5 ++++ 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/app/api/package.json b/app/api/package.json index 6347688..27bd019 100644 --- a/app/api/package.json +++ b/app/api/package.json @@ -21,6 +21,7 @@ "@types/nodemailer": "^6.4.2", "concurrently": "^6.0.0", "nodemon": "^2.0.7", - "serverless-dotenv-plugin": "^3.10.0" + "serverless-dotenv-plugin": "^3.10.0", + "serverless-plugin-git-variables": "^5.1.0" } } diff --git a/app/api/src/functions/graphql.ts b/app/api/src/functions/graphql.ts index 5441483..db40c5e 100644 --- a/app/api/src/functions/graphql.ts +++ b/app/api/src/functions/graphql.ts @@ -16,6 +16,10 @@ export const handler = createGraphQLHandler({ sdls, services, plugins: [createSentryApolloPlugin()], + cors: { + origin: '*', + credentials: true, + }, onException: () => { // Disconnect from your database with an unhandled exception. diff --git a/app/serverless.yml b/app/serverless.yml index d21e849..45fef4b 100644 --- a/app/serverless.yml +++ b/app/serverless.yml @@ -8,6 +8,7 @@ service: cadhubapi plugins: - serverless-dotenv-plugin - serverless-binary-cors + - serverless-plugin-git-variables custom: dotenv: @@ -65,14 +66,18 @@ functions: environment: SENTRY_DSN: ${env:SENTRY_DSN} DATABASE_URL: ${env:DATABASE_URL_PROD} + COMMIT_REF: ${git:sha1} + CONTEXT: TODO handler: check-user-name.handler events: - httpApi: path: /.netlify/functions/check-user-name method: GET + # cors: true - httpApi: path: /.netlify/functions/check-user-name method: POST + # cors: true graphql: description: graphql function deployed on AWS Lambda package: @@ -88,15 +93,38 @@ functions: EMAIL_PASSWORD: ${env:EMAIL_PASSWORD} SENTRY_DSN: ${env:SENTRY_DSN} DATABASE_URL: ${env:DATABASE_URL_PROD} + COMMIT_REF: ${git:sha1} + CONTEXT: TODO # YOUR_FIRST_ENV_VARIABLE: ${env:YOUR_FIRST_ENV_VARIABLE} handler: graphql.handler events: - httpApi: path: /.netlify/functions/graphql method: GET + # cors: true - httpApi: path: /.netlify/functions/graphql method: POST + # cors: true + # identity-signup: # this is netlify specific and is related to go true auth, so we'll continue having that deployed on netlify + # description: identity-signup function deployed on AWS Lambda + # package: + # artifact: api/dist/zipball/identity-signup.zip # This is the default location of the zip file generated during the deploy command. + # memorySize: 1024 # mb + # timeout: 25 # seconds (max: 29) + # tags: # Tags for this specific lambda function + # endpoint: /.netlify/functions/identity-signup + # # Uncomment this section to add environment variables either from the Serverless dotenv plugin or using Serverless params + # # environment: + # # YOUR_FIRST_ENV_VARIABLE: ${env:YOUR_FIRST_ENV_VARIABLE} + # handler: identity-signup.handler + # events: + # - httpApi: + # path: /.netlify/functions/identity-signup + # method: GET + # - httpApi: + # path: /.netlify/functions/identity-signup + # method: POST openscadpreview: image: name: openscadimage @@ -136,25 +164,6 @@ functions: method: post cors: true timeout: 30 - # identity-signup.ts: # this is netlify specific and is related to go true auth, so we'll continue having that deployed on netlify - # description: identity-signup.ts function deployed on AWS Lambda - # package: - # artifact: api/dist/zipball/identity-signup.ts.zip # This is the default location of the zip file generated during the deploy command. - # memorySize: 1024 # mb - # timeout: 25 # seconds (max: 29) - # tags: # Tags for this specific lambda function - # endpoint: /.netlify/functions/identity-signup.ts - # # Uncomment this section to add environment variables either from the Serverless dotenv plugin or using Serverless params - # # environment: - # # YOUR_FIRST_ENV_VARIABLE: ${env:YOUR_FIRST_ENV_VARIABLE} - # handler: identity-signup.ts.handler - # events: - # - httpApi: - # path: /.netlify/functions/identity-signup.ts - # method: GET - # - httpApi: - # path: /.netlify/functions/identity-signup.ts - # method: POST # this allows browsers to see error responses. resources: diff --git a/app/yarn.lock b/app/yarn.lock index cef1dbe..76efa61 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -17132,6 +17132,11 @@ serverless-dotenv-plugin@^3.10.0: dotenv "^10.0.0" dotenv-expand "^5.1.0" +serverless-plugin-git-variables@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/serverless-plugin-git-variables/-/serverless-plugin-git-variables-5.1.0.tgz#668aceed366d647ac0143c4a8bc4782b7536df12" + integrity sha512-72HcfC6KIpsiPimJrdAknvtYEfERgm1+f6TPj3mvA5Dd+2xDFoi6bItyRwqqepoCshL77AFfzpmlxYn58Ez0rw== + set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"