-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathv2.ts
76 lines (64 loc) · 1.9 KB
/
v2.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
export type { Context } from '@netlify/serverless-functions-api'
type Path = `/${string}`
type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'
type CronSchedule = string
type RateLimitAggregator = 'domain' | 'ip'
type RateLimitAction = 'rate_limit' | 'rewrite'
interface RateLimitConfig {
action?: RateLimitAction
aggregateBy?: RateLimitAggregator | RateLimitAggregator[]
to?: string
windowSize: number
}
interface BaseConfig {
/**
* Configures the function to serve any static files that match the request
* URL and render the function only if no matching files exist.
*/
preferStatic?: boolean
/**
* Limits the HTTP methods for which the function will run. If not set, the
* function will run for all supported methods.
*/
method?: HTTPMethod | HTTPMethod[]
rateLimit?: RateLimitConfig
}
interface ConfigWithPath extends BaseConfig {
/**
* One or more URL paths for which the function will not run, even if they
* match a path defined with the `path` property. Paths must begin with a
* forward slash.
*
* {@link} https://ntl.fyi/func-routing
*/
excludedPath?: Path | Path[]
/**
* One or more URL paths for which the function will run. Paths must begin
* with a forward slash.
*
* {@link} https://ntl.fyi/func-routing
*/
path?: Path | Path[]
/**
* The `schedule` property cannot be used when `path` is used.
*/
schedule?: never
}
interface ConfigWithSchedule extends BaseConfig {
/**
* The `excludedPath` property cannot be used when `schedule` is used.
*/
excludedPath?: never
/**
* The `path` property cannot be used when `schedule` is used.
*/
path?: never
/**
* Cron expression representing the schedule at which the function will be
* automatically invoked.
*
* {@link} https://ntl.fyi/sched-func
*/
schedule: CronSchedule
}
export type Config = ConfigWithPath | ConfigWithSchedule