1 |
|
2 |
|
3 |
|
4 | import {
|
5 | CosmosDBTrigger,
|
6 | CosmosDBTriggerOptions,
|
7 | EventGridTrigger,
|
8 | EventGridTriggerOptions,
|
9 | EventHubTrigger,
|
10 | EventHubTriggerOptions,
|
11 | FunctionTrigger,
|
12 | GenericTriggerOptions,
|
13 | HttpTrigger,
|
14 | HttpTriggerOptions,
|
15 | ServiceBusQueueTrigger,
|
16 | ServiceBusQueueTriggerOptions,
|
17 | ServiceBusTopicTrigger,
|
18 | ServiceBusTopicTriggerOptions,
|
19 | StorageBlobTrigger,
|
20 | StorageBlobTriggerOptions,
|
21 | StorageQueueTrigger,
|
22 | StorageQueueTriggerOptions,
|
23 | TimerTrigger,
|
24 | TimerTriggerOptions,
|
25 | WarmupTrigger,
|
26 | WarmupTriggerOptions,
|
27 | } from '@azure/functions';
|
28 | import { addBindingName } from './addBindingName';
|
29 |
|
30 | export function http(options: HttpTriggerOptions): HttpTrigger {
|
31 | return addTriggerBindingName({
|
32 | ...options,
|
33 | authLevel: options.authLevel || 'anonymous',
|
34 | methods: options.methods || ['GET', 'POST'],
|
35 | type: 'httpTrigger',
|
36 | });
|
37 | }
|
38 |
|
39 | export function timer(options: TimerTriggerOptions): TimerTrigger {
|
40 | return addTriggerBindingName({
|
41 | ...options,
|
42 | type: 'timerTrigger',
|
43 | });
|
44 | }
|
45 |
|
46 | export function storageBlob(options: StorageBlobTriggerOptions): StorageBlobTrigger {
|
47 | return addTriggerBindingName({
|
48 | ...options,
|
49 | type: 'blobTrigger',
|
50 | });
|
51 | }
|
52 |
|
53 | export function storageQueue(options: StorageQueueTriggerOptions): StorageQueueTrigger {
|
54 | return addTriggerBindingName({
|
55 | ...options,
|
56 | type: 'queueTrigger',
|
57 | });
|
58 | }
|
59 |
|
60 | export function serviceBusQueue(options: ServiceBusQueueTriggerOptions): ServiceBusQueueTrigger {
|
61 | return addTriggerBindingName({
|
62 | ...options,
|
63 | type: 'serviceBusTrigger',
|
64 | });
|
65 | }
|
66 |
|
67 | export function serviceBusTopic(options: ServiceBusTopicTriggerOptions): ServiceBusTopicTrigger {
|
68 | return addTriggerBindingName({
|
69 | ...options,
|
70 | type: 'serviceBusTrigger',
|
71 | });
|
72 | }
|
73 |
|
74 | export function eventHub(options: EventHubTriggerOptions): EventHubTrigger {
|
75 | return addTriggerBindingName({
|
76 | ...options,
|
77 | type: 'eventHubTrigger',
|
78 | });
|
79 | }
|
80 |
|
81 | export function eventGrid(options: EventGridTriggerOptions): EventGridTrigger {
|
82 | return addTriggerBindingName({
|
83 | ...options,
|
84 | type: 'eventGridTrigger',
|
85 | });
|
86 | }
|
87 |
|
88 | export function cosmosDB(options: CosmosDBTriggerOptions): CosmosDBTrigger {
|
89 | return addTriggerBindingName({
|
90 | ...options,
|
91 | type: 'cosmosDBTrigger',
|
92 | });
|
93 | }
|
94 |
|
95 | export function warmup(options: WarmupTriggerOptions): WarmupTrigger {
|
96 | return addTriggerBindingName({
|
97 | ...options,
|
98 | type: 'warmupTrigger',
|
99 | });
|
100 | }
|
101 |
|
102 | export function generic(options: GenericTriggerOptions): FunctionTrigger {
|
103 | return addTriggerBindingName(options);
|
104 | }
|
105 |
|
106 | function addTriggerBindingName<T extends { type: string; name?: string }>(binding: T): T & { name: string } {
|
107 | return addBindingName(binding, 'Trigger');
|
108 | }
|