forked from charmverse/app.charmverse.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
63 lines (55 loc) · 1.91 KB
/
serverless.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
service: cvServerless
frameworkVersion: "4"
# Create an optimized package for our functions
package:
individually: true
patterns:
- serverless/*.node
- serverless/schema.prisma
plugins:
# This plugins gives superpowers to serverless and allows us to deploy SQS queues easily
- serverless-lift
- serverless-scriptable-plugin
- serverless-offline
custom:
# esbuild:
# external: ["canvas"]
# watch:
# pattern: ["serverless/**/*.ts"] # match only typescript files in serverless directory
scriptHooks:
package:initialize: node ./copyPrismaFiles.js
# This uses the lift plugin to generate our SQS setup in AWS
# Based on https://github.com/getlift/lift/blob/master/docs/queue.md
constructs:
webhook-queue:
type: queue
# Setup the queue as FIFO
fifo: true
# maxRetries: 5 <-- Adjust retries attempt if the job fails, default to 3
worker:
# Function responsible for handle messages in the queue
handler: serverless/handler.webhookWorker
environment:
DATABASE_URL: ${env:DATABASE_URL}
CREDENTIAL_WALLET_KEY: ${env:CREDENTIAL_WALLET_KEY}
MAILGUN_DOMAIN: ${env:MAILGUN_DOMAIN}
MAILGUN_API_KEY: ${env:MAILGUN_API_KEY}
PERMISSIONS_API_URL: ${env:PERMISSIONS_API_URL}
DOMAIN: https://app.charmverse.io
extensions:
queue:
Properties:
# Using predictable queue names, allows us to be consistent across every deployments
# We can use branch names as stages, so each deployed env can have their own queue
QueueName: charmverse-serverless-queue-${sls:stage}.fifo
provider:
name: aws
runtime: nodejs18.x
deploymentMethod: direct
functions:
# This function is purely for testing our implementation, it received a webhook call and logs it
# Returns a 200 HTTP response
webhookChecker:
handler: serverless/handler.webhookChecker
events:
- httpApi: "POST /webhook"