Initial rw serverless setup

This commit is contained in:
Kurt Hutten
2021-11-20 17:36:06 +11:00
parent e9859d85b8
commit 53a6639fd1
5 changed files with 2507 additions and 1352 deletions

4
app/.gitignore vendored
View File

@@ -1,3 +1,7 @@
dist
web/types/graphql.d.ts
api/types/graphql.d.ts
# Deployment
.serverless

View File

@@ -5,7 +5,7 @@ datasource db {
generator client {
provider = "prisma-client-js"
binaryTargets = "native"
binaryTargets = ["native", "rhel-openssl-1.0.x"]
}
// sqlLight does not suport enums so we can't use enums until we set up postgresql in dev mode

View File

@@ -17,8 +17,10 @@
"serverless-binary-cors": "^0.0.1"
},
"devDependencies": {
"@netlify/zip-it-and-ship-it": "^4.30.0",
"@types/nodemailer": "^6.4.2",
"concurrently": "^6.0.0",
"nodemon": "^2.0.7"
"nodemon": "^2.0.7",
"serverless-dotenv-plugin": "^3.10.0"
}
}
}

101
app/serverless.yml Normal file
View File

@@ -0,0 +1,101 @@
# See the full yml reference at https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/
service: cadhubapi
# Uncomment org and app if you want to integrate your deployment with the Serverless dashboard. See https://www.serverless.com/framework/docs/dashboard/ for more details.
# org: your-org
# app: your-app
plugins:
- serverless-dotenv-plugin
custom:
dotenv:
include:
- DATABASE_URL_PROD
- CLOUDINARY_API_KEY
- CLOUDINARY_API_SECRET
- EMAIL_PASSWORD
- SENTRY_DSN
# - # List the environment variables you want to include from your .env file here.
provider:
name: aws
runtime: nodejs12.x
region: us-east-2 # This is the AWS region where the service will be deployed.
httpApi: # HTTP API is used by default. To learn about the available options in API Gateway, see https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html
cors: true
payload: '1.0'
stackTags: # Add CloudFormation stack tags here
source: serverless
name: Redwood Lambda API with HTTP API Gateway
tags: # Add service wide tags here
name: Redwood Lambda API with HTTP API Gateway
package:
individually: true
functions:
check-user-name:
description: check-user-name function deployed on AWS Lambda
package:
artifact: api/dist/zipball/check-user-name.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/check-user-name
# Uncomment this section to add environment variables either from the Serverless dotenv plugin or using Serverless params
environment:
SENTRY_DSN: ${env:SENTRY_DSN}
DATABASE_URL: ${env:DATABASE_URL_PROD}
handler: check-user-name.handler
events:
- httpApi:
path: /.netlify/functions/check-user-name
method: GET
- httpApi:
path: /.netlify/functions/check-user-name
method: POST
graphql:
description: graphql function deployed on AWS Lambda
package:
artifact: api/dist/zipball/graphql.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/graphql
# Uncomment this section to add environment variables either from the Serverless dotenv plugin or using Serverless params
environment:
CLOUDINARY_API_KEY: ${env:CLOUDINARY_API_KEY}
CLOUDINARY_API_SECRET: ${env:CLOUDINARY_API_SECRET}
EMAIL_PASSWORD: ${env:EMAIL_PASSWORD}
SENTRY_DSN: ${env:SENTRY_DSN}
DATABASE_URL: ${env:DATABASE_URL_PROD}
# YOUR_FIRST_ENV_VARIABLE: ${env:YOUR_FIRST_ENV_VARIABLE}
handler: graphql.handler
events:
- httpApi:
path: /.netlify/functions/graphql
method: GET
- httpApi:
path: /.netlify/functions/graphql
method: POST
# identity-signup.ts:
# 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

File diff suppressed because it is too large Load Diff