-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathform-builder-custom-api-trigger.ts
42 lines (41 loc) · 1.67 KB
/
form-builder-custom-api-trigger.ts
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
// api/formBuilder/src/index.ts
import { createHandler } from "@webiny/handler";
import apolloServerPlugins from "@webiny/handler-apollo-server";
import dbProxyPlugins from "@webiny/api-plugin-commodo-db-proxy";
import securityServicePlugins from "@webiny/api-security/plugins/service";
import i18nServicePlugins from "@webiny/api-i18n/plugins/service";
import formBuilderPlugins from "@webiny/api-form-builder/plugins";
import useSsrCacheTagsPlugins from "@webiny/api-form-builder/plugins/useSsrCacheTags";
import settingsManagerPlugins from "@webiny/api-settings-manager/client";
export const handler = createHandler(
apolloServerPlugins({
debug: process.env.DEBUG,
server: {
introspection: process.env.GRAPHQL_INTROSPECTION,
playground: process.env.GRAPHQL_PLAYGROUND
}
}),
dbProxyPlugins({ functionName: process.env.DB_PROXY_FUNCTION }),
settingsManagerPlugins({ functionName: process.env.SETTINGS_MANAGER_FUNCTION }),
securityServicePlugins({
token: {
expiresIn: process.env.JWT_TOKEN_EXPIRES_IN,
secret: process.env.JWT_TOKEN_SECRET
},
validateAccessTokenFunction: process.env.VALIDATE_ACCESS_TOKEN_FUNCTION
}),
i18nServicePlugins({
localesFunction: process.env.I18N_LOCALES_FUNCTION
}),
formBuilderPlugins(),
useSsrCacheTagsPlugins(),
// The custom form submission trigger - sends an e-mail to a custom e-mail address you define.
{
type: "form-trigger-handler",
trigger: "e-mail",
async handle({ trigger, data, formSubmission }) {
const myEmailClient = ...;
myEmailClient.send(data)
}
}
);