effortless-aws 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-AHRNISIY.js → chunk-5L76NICW.js} +47 -113
- package/dist/cli/index.js +2358 -1939
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +338 -389
- package/dist/index.js +1512 -95
- package/dist/index.js.map +1 -1
- package/dist/runtime/wrap-app.js +30 -25
- package/dist/runtime/wrap-fifo-queue.js +37 -33
- package/dist/runtime/wrap-http.js +31 -27
- package/dist/runtime/wrap-table-stream.js +48 -44
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -47,21 +47,26 @@ type EffortlessConfig = {
|
|
|
47
47
|
handlers?: string | string[];
|
|
48
48
|
/**
|
|
49
49
|
* Default settings applied to all handlers unless overridden.
|
|
50
|
+
*
|
|
51
|
+
* All Lambdas run on ARM64 (Graviton2) architecture — ~20% cheaper than x86_64
|
|
52
|
+
* with better price-performance for most workloads.
|
|
50
53
|
*/
|
|
51
54
|
defaults?: {
|
|
52
55
|
/**
|
|
53
|
-
* Lambda memory in MB.
|
|
56
|
+
* Lambda memory in MB. AWS allocates proportional CPU —
|
|
57
|
+
* 1769 MB gives one full vCPU.
|
|
54
58
|
* @default 256
|
|
55
59
|
*/
|
|
56
60
|
memory?: number;
|
|
57
61
|
/**
|
|
58
62
|
* Lambda timeout as a human-readable string.
|
|
63
|
+
* AWS maximum is 15 minutes.
|
|
59
64
|
* @example "30 seconds", "5 minutes"
|
|
60
65
|
*/
|
|
61
66
|
timeout?: string;
|
|
62
67
|
/**
|
|
63
|
-
* Lambda runtime.
|
|
64
|
-
* @default "
|
|
68
|
+
* Node.js Lambda runtime version.
|
|
69
|
+
* @default "nodejs24.x"
|
|
65
70
|
*/
|
|
66
71
|
runtime?: string;
|
|
67
72
|
};
|
|
@@ -83,9 +88,6 @@ type EffortlessConfig = {
|
|
|
83
88
|
*/
|
|
84
89
|
declare const defineConfig: (config: EffortlessConfig) => EffortlessConfig;
|
|
85
90
|
|
|
86
|
-
type AwsService = "dynamodb" | "s3" | "sqs" | "sns" | "ses" | "ssm" | "lambda" | "events" | "secretsmanager" | "cognito-idp" | "logs";
|
|
87
|
-
type Permission = `${AwsService}:${string}` | (string & {});
|
|
88
|
-
|
|
89
91
|
/**
|
|
90
92
|
* Query parameters for TableClient.query()
|
|
91
93
|
*/
|
|
@@ -143,54 +145,6 @@ type TableClient<T = Record<string, unknown>> = {
|
|
|
143
145
|
tableName: string;
|
|
144
146
|
};
|
|
145
147
|
|
|
146
|
-
type AnyParamRef = ParamRef<any>;
|
|
147
|
-
/**
|
|
148
|
-
* Reference to an SSM Parameter Store parameter.
|
|
149
|
-
*
|
|
150
|
-
* @typeParam T - The resolved type after optional transform (default: string)
|
|
151
|
-
*/
|
|
152
|
-
type ParamRef<T = string> = {
|
|
153
|
-
readonly __brand: "effortless-param";
|
|
154
|
-
readonly key: string;
|
|
155
|
-
readonly transform?: (raw: string) => T;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* Maps a params declaration to resolved value types.
|
|
159
|
-
*
|
|
160
|
-
* @typeParam P - Record of param names to ParamRef instances
|
|
161
|
-
*/
|
|
162
|
-
type ResolveParams<P> = {
|
|
163
|
-
[K in keyof P]: P[K] extends ParamRef<infer T> ? T : never;
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* Declare an SSM Parameter Store parameter.
|
|
167
|
-
*
|
|
168
|
-
* The key is combined with project and stage at deploy time to form the full
|
|
169
|
-
* SSM path: `/${project}/${stage}/${key}`.
|
|
170
|
-
*
|
|
171
|
-
* @param key - Parameter key (e.g., "database-url")
|
|
172
|
-
* @param transform - Optional function to transform the raw string value
|
|
173
|
-
* @returns A ParamRef used by the deployment and runtime systems
|
|
174
|
-
*
|
|
175
|
-
* @example Simple string parameter
|
|
176
|
-
* ```typescript
|
|
177
|
-
* params: {
|
|
178
|
-
* dbUrl: param("database-url"),
|
|
179
|
-
* }
|
|
180
|
-
* ```
|
|
181
|
-
*
|
|
182
|
-
* @example With transform (e.g., TOML parsing)
|
|
183
|
-
* ```typescript
|
|
184
|
-
* import TOML from "smol-toml";
|
|
185
|
-
*
|
|
186
|
-
* params: {
|
|
187
|
-
* config: param("app-config", TOML.parse),
|
|
188
|
-
* }
|
|
189
|
-
* ```
|
|
190
|
-
*/
|
|
191
|
-
declare function param(key: string): ParamRef<string>;
|
|
192
|
-
declare function param<T>(key: string, transform: (raw: string) => T): ParamRef<T>;
|
|
193
|
-
|
|
194
148
|
type AnyTableHandler$2 = TableHandler<any, any, any, any, any, any>;
|
|
195
149
|
/** Maps a deps declaration to resolved runtime client types */
|
|
196
150
|
type ResolveDeps$2<D> = {
|
|
@@ -212,9 +166,7 @@ type StreamView = "NEW_AND_OLD_IMAGES" | "NEW_IMAGE" | "OLD_IMAGE" | "KEYS_ONLY"
|
|
|
212
166
|
/**
|
|
213
167
|
* Configuration options extracted from DefineTableOptions (without onRecord/context)
|
|
214
168
|
*/
|
|
215
|
-
type TableConfig = {
|
|
216
|
-
/** Table/handler name. Defaults to export name if not specified */
|
|
217
|
-
name?: string;
|
|
169
|
+
type TableConfig = LambdaWithPermissions & {
|
|
218
170
|
/** Partition key definition */
|
|
219
171
|
pk: TableKey;
|
|
220
172
|
/** Sort key definition (optional) */
|
|
@@ -231,14 +183,6 @@ type TableConfig = {
|
|
|
231
183
|
batchWindow?: number;
|
|
232
184
|
/** Where to start reading the stream (default: "LATEST") */
|
|
233
185
|
startingPosition?: "LATEST" | "TRIM_HORIZON";
|
|
234
|
-
/** Lambda memory in MB (default: 256) */
|
|
235
|
-
memory?: number;
|
|
236
|
-
/** Lambda timeout in seconds (default: 30) */
|
|
237
|
-
timeout?: number;
|
|
238
|
-
/** Additional IAM permissions for the Lambda */
|
|
239
|
-
permissions?: Permission[];
|
|
240
|
-
/** Enable observability logging to platform table (default: true) */
|
|
241
|
-
observe?: boolean;
|
|
242
186
|
};
|
|
243
187
|
/**
|
|
244
188
|
* DynamoDB stream record passed to onRecord callback
|
|
@@ -430,290 +374,73 @@ type TableHandler<T = Record<string, unknown>, C = undefined, R = void, D = unde
|
|
|
430
374
|
*/
|
|
431
375
|
declare const defineTable: <T = Record<string, unknown>, C = undefined, R = void, D extends Record<string, AnyTableHandler$2> | undefined = undefined, P extends Record<string, AnyParamRef> | undefined = undefined, S extends string[] | undefined = undefined>(options: DefineTableOptions<T, C, R, D, P, S>) => TableHandler<T, C, R, D, P, S>;
|
|
432
376
|
|
|
433
|
-
type AnyTableHandler$1 = TableHandler<any, any, any, any, any, any>;
|
|
434
|
-
/** Maps a deps declaration to resolved runtime client types */
|
|
435
|
-
type ResolveDeps$1<D> = {
|
|
436
|
-
[K in keyof D]: D[K] extends TableHandler<infer T, any, any, any, any> ? TableClient<T> : never;
|
|
437
|
-
};
|
|
438
|
-
/** HTTP methods supported by API Gateway */
|
|
439
|
-
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
440
|
-
/** Short content-type aliases for common response formats */
|
|
441
|
-
type ContentType = "json" | "html" | "text" | "css" | "js" | "xml" | "csv" | "svg";
|
|
442
|
-
/**
|
|
443
|
-
* Incoming HTTP request object passed to the handler
|
|
444
|
-
*/
|
|
445
|
-
type HttpRequest = {
|
|
446
|
-
/** HTTP method (GET, POST, etc.) */
|
|
447
|
-
method: string;
|
|
448
|
-
/** Request path (e.g., "/users/123") */
|
|
449
|
-
path: string;
|
|
450
|
-
/** Request headers */
|
|
451
|
-
headers: Record<string, string | undefined>;
|
|
452
|
-
/** Query string parameters */
|
|
453
|
-
query: Record<string, string | undefined>;
|
|
454
|
-
/** Path parameters extracted from route (e.g., {id} -> params.id) */
|
|
455
|
-
params: Record<string, string | undefined>;
|
|
456
|
-
/** Parsed request body (JSON parsed if Content-Type is application/json) */
|
|
457
|
-
body: unknown;
|
|
458
|
-
/** Raw unparsed request body */
|
|
459
|
-
rawBody?: string;
|
|
460
|
-
};
|
|
461
377
|
/**
|
|
462
|
-
*
|
|
378
|
+
* Configuration for a Lambda-served static site (API Gateway + Lambda)
|
|
463
379
|
*/
|
|
464
|
-
type
|
|
465
|
-
/**
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
* - `"js"` → `application/javascript; charset=utf-8`
|
|
476
|
-
* - `"xml"` → `application/xml; charset=utf-8`
|
|
477
|
-
* - `"csv"` → `text/csv; charset=utf-8`
|
|
478
|
-
* - `"svg"` → `image/svg+xml; charset=utf-8`
|
|
479
|
-
*/
|
|
480
|
-
contentType?: ContentType;
|
|
481
|
-
/** Response headers (use for custom content-types not covered by contentType) */
|
|
482
|
-
headers?: Record<string, string>;
|
|
380
|
+
type AppConfig = LambdaConfig & {
|
|
381
|
+
/** Base URL path the site is served under (e.g., "/app") */
|
|
382
|
+
path?: string;
|
|
383
|
+
/** Directory containing the static site files, relative to project root */
|
|
384
|
+
dir: string;
|
|
385
|
+
/** Default file for directory requests (default: "index.html") */
|
|
386
|
+
index?: string;
|
|
387
|
+
/** SPA mode: serve index.html for all paths that don't match a file (default: false) */
|
|
388
|
+
spa?: boolean;
|
|
389
|
+
/** Shell command to run before deploy to generate site content (e.g., "npx astro build") */
|
|
390
|
+
build?: string;
|
|
483
391
|
};
|
|
484
392
|
/**
|
|
485
|
-
*
|
|
393
|
+
* Internal handler object created by defineApp
|
|
394
|
+
* @internal
|
|
486
395
|
*/
|
|
487
|
-
type
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
/** HTTP method for the route */
|
|
491
|
-
method: HttpMethod;
|
|
492
|
-
/** Route path (e.g., "/api/users", "/api/users/{id}") */
|
|
493
|
-
path: string;
|
|
494
|
-
/** Lambda memory in MB (default: 256) */
|
|
495
|
-
memory?: number;
|
|
496
|
-
/** Lambda timeout in seconds (default: 30) */
|
|
497
|
-
timeout?: number;
|
|
498
|
-
/** Additional IAM permissions for the Lambda */
|
|
499
|
-
permissions?: Permission[];
|
|
500
|
-
/** Enable observability logging to platform table (default: true) */
|
|
501
|
-
observe?: boolean;
|
|
396
|
+
type AppHandler = {
|
|
397
|
+
readonly __brand: "effortless-app";
|
|
398
|
+
readonly config: AppConfig;
|
|
502
399
|
};
|
|
503
400
|
/**
|
|
504
|
-
*
|
|
401
|
+
* Deploy a static site via Lambda + API Gateway.
|
|
402
|
+
* Files are bundled into the Lambda ZIP and served with auto-detected content types.
|
|
505
403
|
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* @
|
|
509
|
-
* @
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
deps: ResolveDeps$1<D>;
|
|
519
|
-
}) & ([P] extends [undefined] ? {} : {
|
|
520
|
-
params: ResolveParams<P>;
|
|
521
|
-
}) & ([S] extends [undefined] ? {} : {
|
|
522
|
-
readStatic: (path: string) => string;
|
|
523
|
-
})) => Promise<HttpResponse>;
|
|
524
|
-
/**
|
|
525
|
-
* Context factory type — conditional on whether params are declared.
|
|
526
|
-
* Without params: `() => C | Promise<C>`
|
|
527
|
-
* With params: `(args: { params: ResolveParams<P> }) => C | Promise<C>`
|
|
404
|
+
* For CDN-backed sites (S3 + CloudFront), use {@link defineStaticSite} instead.
|
|
405
|
+
*
|
|
406
|
+
* @param options - Site configuration: path, directory, optional SPA mode
|
|
407
|
+
* @returns Handler object used by the deployment system
|
|
408
|
+
*
|
|
409
|
+
* @example Basic static site
|
|
410
|
+
* ```typescript
|
|
411
|
+
* export const app = defineApp({
|
|
412
|
+
* path: "/app",
|
|
413
|
+
* dir: "src/webapp",
|
|
414
|
+
* });
|
|
415
|
+
* ```
|
|
528
416
|
*/
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}) => C | Promise<C>;
|
|
417
|
+
declare const defineApp: (options: AppConfig) => AppHandler;
|
|
418
|
+
|
|
532
419
|
/**
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
* @typeParam T - Type of the validated request body (inferred from schema function)
|
|
536
|
-
* @typeParam C - Type of the context/dependencies returned by context function
|
|
537
|
-
* @typeParam D - Type of the deps (from deps declaration)
|
|
538
|
-
* @typeParam P - Type of the params (from params declaration)
|
|
420
|
+
* Configuration for a static site handler (S3 + CloudFront)
|
|
539
421
|
*/
|
|
540
|
-
type
|
|
541
|
-
/**
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* Error handler called when schema validation or onRequest throws.
|
|
553
|
-
* Receives the error and request, returns an HttpResponse.
|
|
554
|
-
* If not provided, defaults to 400 for validation errors and 500 for handler errors.
|
|
555
|
-
*/
|
|
556
|
-
onError?: (error: unknown, req: HttpRequest) => HttpResponse;
|
|
557
|
-
/**
|
|
558
|
-
* Factory function to create context/dependencies for the request handler.
|
|
559
|
-
* Called once on cold start, result is cached and reused across invocations.
|
|
560
|
-
* When params are declared, receives resolved params as argument.
|
|
561
|
-
* Supports both sync and async return values.
|
|
562
|
-
*/
|
|
563
|
-
context?: ContextFactory$1<C, P>;
|
|
564
|
-
/**
|
|
565
|
-
* Dependencies on other handlers (tables, queues, etc.).
|
|
566
|
-
* Typed clients are injected into the handler via the `deps` argument.
|
|
567
|
-
*/
|
|
568
|
-
deps?: D;
|
|
569
|
-
/**
|
|
570
|
-
* SSM Parameter Store parameters.
|
|
571
|
-
* Declare with `param()` helper. Values are fetched and cached at cold start.
|
|
572
|
-
* Typed values are injected into the handler via the `params` argument.
|
|
573
|
-
*/
|
|
574
|
-
params?: P;
|
|
575
|
-
/**
|
|
576
|
-
* Static file glob patterns to bundle into the Lambda ZIP.
|
|
577
|
-
* Files are accessible at runtime via the `readStatic` callback argument.
|
|
578
|
-
*/
|
|
579
|
-
static?: S;
|
|
580
|
-
/** HTTP request handler function */
|
|
581
|
-
onRequest: HttpHandlerFn<T, C, D, P, S>;
|
|
422
|
+
type StaticSiteConfig = {
|
|
423
|
+
/** Handler name. Defaults to export name if not specified */
|
|
424
|
+
name?: string;
|
|
425
|
+
/** Directory containing the static site files, relative to project root */
|
|
426
|
+
dir: string;
|
|
427
|
+
/** Default file for directory requests (default: "index.html") */
|
|
428
|
+
index?: string;
|
|
429
|
+
/** SPA mode: serve index.html for all paths that don't match a file (default: false) */
|
|
430
|
+
spa?: boolean;
|
|
431
|
+
/** Shell command to run before deploy to generate site content (e.g., "npx astro build") */
|
|
432
|
+
build?: string;
|
|
582
433
|
};
|
|
583
434
|
/**
|
|
584
|
-
* Internal handler object created by
|
|
435
|
+
* Internal handler object created by defineStaticSite
|
|
585
436
|
* @internal
|
|
586
437
|
*/
|
|
587
|
-
type
|
|
588
|
-
readonly __brand: "effortless-
|
|
589
|
-
readonly config:
|
|
590
|
-
readonly schema?: (input: unknown) => T;
|
|
591
|
-
readonly onError?: (error: unknown, req: HttpRequest) => HttpResponse;
|
|
592
|
-
readonly context?: (...args: any[]) => C | Promise<C>;
|
|
593
|
-
readonly deps?: D;
|
|
594
|
-
readonly params?: P;
|
|
595
|
-
readonly static?: string[];
|
|
596
|
-
readonly onRequest: HttpHandlerFn<T, C, D, P, S>;
|
|
438
|
+
type StaticSiteHandler = {
|
|
439
|
+
readonly __brand: "effortless-static-site";
|
|
440
|
+
readonly config: StaticSiteConfig;
|
|
597
441
|
};
|
|
598
442
|
/**
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
* @typeParam T - Type of the validated request body (inferred from schema function)
|
|
602
|
-
* @typeParam C - Type of the context/dependencies (inferred from context function)
|
|
603
|
-
* @typeParam D - Type of the deps (from deps declaration)
|
|
604
|
-
* @typeParam P - Type of the params (from params declaration)
|
|
605
|
-
* @param options - Configuration, optional schema, optional context factory, and request handler
|
|
606
|
-
* @returns Handler object used by the deployment system
|
|
607
|
-
*
|
|
608
|
-
* @example Basic GET endpoint
|
|
609
|
-
* ```typescript
|
|
610
|
-
* export const hello = defineHttp({
|
|
611
|
-
* method: "GET",
|
|
612
|
-
* path: "/hello",
|
|
613
|
-
* onRequest: async ({ req }) => ({
|
|
614
|
-
* status: 200,
|
|
615
|
-
* body: { message: "Hello World!" }
|
|
616
|
-
* })
|
|
617
|
-
* });
|
|
618
|
-
* ```
|
|
619
|
-
*
|
|
620
|
-
* @example With SSM parameters
|
|
621
|
-
* ```typescript
|
|
622
|
-
* import { param } from "effortless-aws";
|
|
623
|
-
*
|
|
624
|
-
* export const api = defineHttp({
|
|
625
|
-
* method: "GET",
|
|
626
|
-
* path: "/orders",
|
|
627
|
-
* params: {
|
|
628
|
-
* dbUrl: param("database-url"),
|
|
629
|
-
* },
|
|
630
|
-
* context: async ({ params }) => ({
|
|
631
|
-
* pool: createPool(params.dbUrl),
|
|
632
|
-
* }),
|
|
633
|
-
* onRequest: async ({ req, ctx, params }) => ({
|
|
634
|
-
* status: 200,
|
|
635
|
-
* body: { dbUrl: params.dbUrl }
|
|
636
|
-
* })
|
|
637
|
-
* });
|
|
638
|
-
* ```
|
|
639
|
-
*/
|
|
640
|
-
declare const defineHttp: <T = undefined, C = undefined, D extends Record<string, AnyTableHandler$1> | undefined = undefined, P extends Record<string, AnyParamRef> | undefined = undefined, S extends string[] | undefined = undefined>(options: DefineHttpOptions<T, C, D, P, S>) => HttpHandler<T, C, D, P, S>;
|
|
641
|
-
|
|
642
|
-
/**
|
|
643
|
-
* Configuration for a Lambda-served static site (API Gateway + Lambda)
|
|
644
|
-
*/
|
|
645
|
-
type AppConfig = {
|
|
646
|
-
/** Handler name. Defaults to export name if not specified */
|
|
647
|
-
name?: string;
|
|
648
|
-
/** Base URL path the site is served under (e.g., "/app") */
|
|
649
|
-
path?: string;
|
|
650
|
-
/** Directory containing the static site files, relative to project root */
|
|
651
|
-
dir: string;
|
|
652
|
-
/** Default file for directory requests (default: "index.html") */
|
|
653
|
-
index?: string;
|
|
654
|
-
/** SPA mode: serve index.html for all paths that don't match a file (default: false) */
|
|
655
|
-
spa?: boolean;
|
|
656
|
-
/** Shell command to run before deploy to generate site content (e.g., "npx astro build") */
|
|
657
|
-
build?: string;
|
|
658
|
-
/** Lambda memory in MB (default: 256) */
|
|
659
|
-
memory?: number;
|
|
660
|
-
/** Lambda timeout in seconds (default: 5) */
|
|
661
|
-
timeout?: number;
|
|
662
|
-
/** Enable observability logging to platform table (default: false) */
|
|
663
|
-
observe?: boolean;
|
|
664
|
-
};
|
|
665
|
-
/**
|
|
666
|
-
* Internal handler object created by defineApp
|
|
667
|
-
* @internal
|
|
668
|
-
*/
|
|
669
|
-
type AppHandler = {
|
|
670
|
-
readonly __brand: "effortless-app";
|
|
671
|
-
readonly config: AppConfig;
|
|
672
|
-
};
|
|
673
|
-
/**
|
|
674
|
-
* Deploy a static site via Lambda + API Gateway.
|
|
675
|
-
* Files are bundled into the Lambda ZIP and served with auto-detected content types.
|
|
676
|
-
*
|
|
677
|
-
* For CDN-backed sites (S3 + CloudFront), use {@link defineStaticSite} instead.
|
|
678
|
-
*
|
|
679
|
-
* @param options - Site configuration: path, directory, optional SPA mode
|
|
680
|
-
* @returns Handler object used by the deployment system
|
|
681
|
-
*
|
|
682
|
-
* @example Basic static site
|
|
683
|
-
* ```typescript
|
|
684
|
-
* export const app = defineApp({
|
|
685
|
-
* path: "/app",
|
|
686
|
-
* dir: "src/webapp",
|
|
687
|
-
* });
|
|
688
|
-
* ```
|
|
689
|
-
*/
|
|
690
|
-
declare const defineApp: (options: AppConfig) => AppHandler;
|
|
691
|
-
|
|
692
|
-
/**
|
|
693
|
-
* Configuration for a static site handler (S3 + CloudFront)
|
|
694
|
-
*/
|
|
695
|
-
type StaticSiteConfig = {
|
|
696
|
-
/** Handler name. Defaults to export name if not specified */
|
|
697
|
-
name?: string;
|
|
698
|
-
/** Directory containing the static site files, relative to project root */
|
|
699
|
-
dir: string;
|
|
700
|
-
/** Default file for directory requests (default: "index.html") */
|
|
701
|
-
index?: string;
|
|
702
|
-
/** SPA mode: serve index.html for all paths that don't match a file (default: false) */
|
|
703
|
-
spa?: boolean;
|
|
704
|
-
/** Shell command to run before deploy to generate site content (e.g., "npx astro build") */
|
|
705
|
-
build?: string;
|
|
706
|
-
};
|
|
707
|
-
/**
|
|
708
|
-
* Internal handler object created by defineStaticSite
|
|
709
|
-
* @internal
|
|
710
|
-
*/
|
|
711
|
-
type StaticSiteHandler = {
|
|
712
|
-
readonly __brand: "effortless-static-site";
|
|
713
|
-
readonly config: StaticSiteConfig;
|
|
714
|
-
};
|
|
715
|
-
/**
|
|
716
|
-
* Deploy a static site via S3 + CloudFront CDN.
|
|
443
|
+
* Deploy a static site via S3 + CloudFront CDN.
|
|
717
444
|
*
|
|
718
445
|
* @param options - Static site configuration: directory, optional SPA mode, build command
|
|
719
446
|
* @returns Handler object used by the deployment system
|
|
@@ -737,9 +464,9 @@ type StaticSiteHandler = {
|
|
|
737
464
|
*/
|
|
738
465
|
declare const defineStaticSite: (options: StaticSiteConfig) => StaticSiteHandler;
|
|
739
466
|
|
|
740
|
-
type AnyTableHandler = TableHandler<any, any, any, any, any, any>;
|
|
467
|
+
type AnyTableHandler$1 = TableHandler<any, any, any, any, any, any>;
|
|
741
468
|
/** Maps a deps declaration to resolved runtime client types */
|
|
742
|
-
type ResolveDeps<D> = {
|
|
469
|
+
type ResolveDeps$1<D> = {
|
|
743
470
|
[K in keyof D]: D[K] extends TableHandler<infer T, any, any, any, any> ? TableClient<T> : never;
|
|
744
471
|
};
|
|
745
472
|
/**
|
|
@@ -775,9 +502,7 @@ type FifoQueueMessage<T = unknown> = {
|
|
|
775
502
|
/**
|
|
776
503
|
* Configuration options for a FIFO queue handler
|
|
777
504
|
*/
|
|
778
|
-
type FifoQueueConfig = {
|
|
779
|
-
/** Handler name. Defaults to export name if not specified */
|
|
780
|
-
name?: string;
|
|
505
|
+
type FifoQueueConfig = LambdaWithPermissions & {
|
|
781
506
|
/** Number of messages per Lambda invocation (1-10 for FIFO, default: 10) */
|
|
782
507
|
batchSize?: number;
|
|
783
508
|
/** Maximum time in seconds to gather messages before invoking (0-300, default: 0) */
|
|
@@ -788,21 +513,13 @@ type FifoQueueConfig = {
|
|
|
788
513
|
retentionPeriod?: number;
|
|
789
514
|
/** Enable content-based deduplication (default: true) */
|
|
790
515
|
contentBasedDeduplication?: boolean;
|
|
791
|
-
/** Lambda memory in MB (default: 256) */
|
|
792
|
-
memory?: number;
|
|
793
|
-
/** Lambda timeout in seconds (default: 30) */
|
|
794
|
-
timeout?: number;
|
|
795
|
-
/** Additional IAM permissions for the Lambda */
|
|
796
|
-
permissions?: Permission[];
|
|
797
|
-
/** Enable observability logging to platform table (default: true) */
|
|
798
|
-
observe?: boolean;
|
|
799
516
|
};
|
|
800
517
|
/**
|
|
801
518
|
* Context factory type — conditional on whether params are declared.
|
|
802
519
|
* Without params: `() => C | Promise<C>`
|
|
803
520
|
* With params: `(args: { params: ResolveParams<P> }) => C | Promise<C>`
|
|
804
521
|
*/
|
|
805
|
-
type ContextFactory<C, P> = [P] extends [undefined] ? () => C | Promise<C> : (args: {
|
|
522
|
+
type ContextFactory$1<C, P> = [P] extends [undefined] ? () => C | Promise<C> : (args: {
|
|
806
523
|
params: ResolveParams<P & {}>;
|
|
807
524
|
}) => C | Promise<C>;
|
|
808
525
|
/**
|
|
@@ -814,7 +531,7 @@ type FifoQueueMessageFn<T = unknown, C = undefined, D = undefined, P = undefined
|
|
|
814
531
|
} & ([C] extends [undefined] ? {} : {
|
|
815
532
|
ctx: C;
|
|
816
533
|
}) & ([D] extends [undefined] ? {} : {
|
|
817
|
-
deps: ResolveDeps<D>;
|
|
534
|
+
deps: ResolveDeps$1<D>;
|
|
818
535
|
}) & ([P] extends [undefined] ? {} : {
|
|
819
536
|
params: ResolveParams<P>;
|
|
820
537
|
}) & ([S] extends [undefined] ? {} : {
|
|
@@ -829,7 +546,7 @@ type FifoQueueBatchFn<T = unknown, C = undefined, D = undefined, P = undefined,
|
|
|
829
546
|
} & ([C] extends [undefined] ? {} : {
|
|
830
547
|
ctx: C;
|
|
831
548
|
}) & ([D] extends [undefined] ? {} : {
|
|
832
|
-
deps: ResolveDeps<D>;
|
|
549
|
+
deps: ResolveDeps$1<D>;
|
|
833
550
|
}) & ([P] extends [undefined] ? {} : {
|
|
834
551
|
params: ResolveParams<P>;
|
|
835
552
|
}) & ([S] extends [undefined] ? {} : {
|
|
@@ -852,7 +569,7 @@ type DefineFifoQueueBase<T = unknown, C = undefined, D = undefined, P = undefine
|
|
|
852
569
|
* Called once on cold start, result is cached and reused across invocations.
|
|
853
570
|
* When params are declared, receives resolved params as argument.
|
|
854
571
|
*/
|
|
855
|
-
context?: ContextFactory<C, P>;
|
|
572
|
+
context?: ContextFactory$1<C, P>;
|
|
856
573
|
/**
|
|
857
574
|
* Dependencies on other handlers (tables, queues, etc.).
|
|
858
575
|
* Typed clients are injected into the handler via the `deps` argument.
|
|
@@ -879,7 +596,7 @@ type DefineFifoQueueWithOnBatch<T = unknown, C = undefined, D = undefined, P = u
|
|
|
879
596
|
onBatch: FifoQueueBatchFn<T, C, D, P, S>;
|
|
880
597
|
onMessage?: never;
|
|
881
598
|
};
|
|
882
|
-
type DefineFifoQueueOptions<T = unknown, C = undefined, D extends Record<string, AnyTableHandler> | undefined = undefined, P extends Record<string, AnyParamRef> | undefined = undefined, S extends string[] | undefined = undefined> = DefineFifoQueueWithOnMessage<T, C, D, P, S> | DefineFifoQueueWithOnBatch<T, C, D, P, S>;
|
|
599
|
+
type DefineFifoQueueOptions<T = unknown, C = undefined, D extends Record<string, AnyTableHandler$1> | undefined = undefined, P extends Record<string, AnyParamRef> | undefined = undefined, S extends string[] | undefined = undefined> = DefineFifoQueueWithOnMessage<T, C, D, P, S> | DefineFifoQueueWithOnBatch<T, C, D, P, S>;
|
|
883
600
|
/**
|
|
884
601
|
* Internal handler object created by defineFifoQueue
|
|
885
602
|
* @internal
|
|
@@ -926,8 +643,80 @@ type FifoQueueHandler<T = unknown, C = undefined, D = undefined, P = undefined,
|
|
|
926
643
|
* });
|
|
927
644
|
* ```
|
|
928
645
|
*/
|
|
929
|
-
declare const defineFifoQueue: <T = unknown, C = undefined, D extends Record<string, AnyTableHandler> | undefined = undefined, P extends Record<string, AnyParamRef> | undefined = undefined, S extends string[] | undefined = undefined>(options: DefineFifoQueueOptions<T, C, D, P, S>) => FifoQueueHandler<T, C, D, P, S>;
|
|
646
|
+
declare const defineFifoQueue: <T = unknown, C = undefined, D extends Record<string, AnyTableHandler$1> | undefined = undefined, P extends Record<string, AnyParamRef> | undefined = undefined, S extends string[] | undefined = undefined>(options: DefineFifoQueueOptions<T, C, D, P, S>) => FifoQueueHandler<T, C, D, P, S>;
|
|
930
647
|
|
|
648
|
+
type AwsService = "dynamodb" | "s3" | "sqs" | "sns" | "ses" | "ssm" | "lambda" | "events" | "secretsmanager" | "cognito-idp" | "logs";
|
|
649
|
+
type Permission = `${AwsService}:${string}` | (string & {});
|
|
650
|
+
/** Logging verbosity level for Lambda handlers */
|
|
651
|
+
type LogLevel = "error" | "info" | "debug";
|
|
652
|
+
/**
|
|
653
|
+
* Common Lambda configuration shared by all handler types.
|
|
654
|
+
*/
|
|
655
|
+
type LambdaConfig = {
|
|
656
|
+
/** Handler name. Defaults to export name if not specified */
|
|
657
|
+
name?: string;
|
|
658
|
+
/** Lambda memory in MB (default: 256) */
|
|
659
|
+
memory?: number;
|
|
660
|
+
/** Lambda timeout in seconds (default: 30) */
|
|
661
|
+
timeout?: number;
|
|
662
|
+
/** Logging verbosity: "error" (errors only), "info" (+ execution summary), "debug" (+ input/output). Default: "info" */
|
|
663
|
+
logLevel?: LogLevel;
|
|
664
|
+
};
|
|
665
|
+
/**
|
|
666
|
+
* Lambda configuration with additional IAM permissions.
|
|
667
|
+
* Used by handler types that support custom permissions (http, table, fifo-queue).
|
|
668
|
+
*/
|
|
669
|
+
type LambdaWithPermissions = LambdaConfig & {
|
|
670
|
+
/** Additional IAM permissions for the Lambda */
|
|
671
|
+
permissions?: Permission[];
|
|
672
|
+
};
|
|
673
|
+
type AnyParamRef = ParamRef<any>;
|
|
674
|
+
/**
|
|
675
|
+
* Reference to an SSM Parameter Store parameter.
|
|
676
|
+
*
|
|
677
|
+
* @typeParam T - The resolved type after optional transform (default: string)
|
|
678
|
+
*/
|
|
679
|
+
type ParamRef<T = string> = {
|
|
680
|
+
readonly __brand: "effortless-param";
|
|
681
|
+
readonly key: string;
|
|
682
|
+
readonly transform?: (raw: string) => T;
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* Maps a params declaration to resolved value types.
|
|
686
|
+
*
|
|
687
|
+
* @typeParam P - Record of param names to ParamRef instances
|
|
688
|
+
*/
|
|
689
|
+
type ResolveParams<P> = {
|
|
690
|
+
[K in keyof P]: P[K] extends ParamRef<infer T> ? T : never;
|
|
691
|
+
};
|
|
692
|
+
/**
|
|
693
|
+
* Declare an SSM Parameter Store parameter.
|
|
694
|
+
*
|
|
695
|
+
* The key is combined with project and stage at deploy time to form the full
|
|
696
|
+
* SSM path: `/${project}/${stage}/${key}`.
|
|
697
|
+
*
|
|
698
|
+
* @param key - Parameter key (e.g., "database-url")
|
|
699
|
+
* @param transform - Optional function to transform the raw string value
|
|
700
|
+
* @returns A ParamRef used by the deployment and runtime systems
|
|
701
|
+
*
|
|
702
|
+
* @example Simple string parameter
|
|
703
|
+
* ```typescript
|
|
704
|
+
* params: {
|
|
705
|
+
* dbUrl: param("database-url"),
|
|
706
|
+
* }
|
|
707
|
+
* ```
|
|
708
|
+
*
|
|
709
|
+
* @example With transform (e.g., TOML parsing)
|
|
710
|
+
* ```typescript
|
|
711
|
+
* import TOML from "smol-toml";
|
|
712
|
+
*
|
|
713
|
+
* params: {
|
|
714
|
+
* config: param("app-config", TOML.parse),
|
|
715
|
+
* }
|
|
716
|
+
* ```
|
|
717
|
+
*/
|
|
718
|
+
declare function param(key: string): ParamRef<string>;
|
|
719
|
+
declare function param<T>(key: string, transform: (raw: string) => T): ParamRef<T>;
|
|
931
720
|
/**
|
|
932
721
|
* Type-only schema helper for handlers.
|
|
933
722
|
*
|
|
@@ -967,43 +756,203 @@ declare const defineFifoQueue: <T = unknown, C = undefined, D extends Record<str
|
|
|
967
756
|
*/
|
|
968
757
|
declare function typed<T>(): (input: unknown) => T;
|
|
969
758
|
|
|
970
|
-
type
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
type
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
759
|
+
type AnyTableHandler = TableHandler<any, any, any, any, any, any>;
|
|
760
|
+
/** Maps a deps declaration to resolved runtime client types */
|
|
761
|
+
type ResolveDeps<D> = {
|
|
762
|
+
[K in keyof D]: D[K] extends TableHandler<infer T, any, any, any, any> ? TableClient<T> : never;
|
|
763
|
+
};
|
|
764
|
+
/** HTTP methods supported by API Gateway */
|
|
765
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
766
|
+
/** Short content-type aliases for common response formats */
|
|
767
|
+
type ContentType = "json" | "html" | "text" | "css" | "js" | "xml" | "csv" | "svg";
|
|
768
|
+
/**
|
|
769
|
+
* Incoming HTTP request object passed to the handler
|
|
770
|
+
*/
|
|
771
|
+
type HttpRequest = {
|
|
772
|
+
/** HTTP method (GET, POST, etc.) */
|
|
773
|
+
method: string;
|
|
774
|
+
/** Request path (e.g., "/users/123") */
|
|
775
|
+
path: string;
|
|
776
|
+
/** Request headers */
|
|
777
|
+
headers: Record<string, string | undefined>;
|
|
778
|
+
/** Query string parameters */
|
|
779
|
+
query: Record<string, string | undefined>;
|
|
780
|
+
/** Path parameters extracted from route (e.g., {id} -> params.id) */
|
|
781
|
+
params: Record<string, string | undefined>;
|
|
782
|
+
/** Parsed request body (JSON parsed if Content-Type is application/json) */
|
|
783
|
+
body: unknown;
|
|
784
|
+
/** Raw unparsed request body */
|
|
785
|
+
rawBody?: string;
|
|
786
|
+
};
|
|
787
|
+
/**
|
|
788
|
+
* HTTP response returned from the handler
|
|
789
|
+
*/
|
|
790
|
+
type HttpResponse = {
|
|
791
|
+
/** HTTP status code (e.g., 200, 404, 500) */
|
|
792
|
+
status: number;
|
|
793
|
+
/** Response body — JSON-serialized by default, or sent as string when contentType is set */
|
|
794
|
+
body?: unknown;
|
|
795
|
+
/**
|
|
796
|
+
* Short content-type alias. Resolves to full MIME type automatically:
|
|
797
|
+
* - `"json"` → `application/json` (default if omitted)
|
|
798
|
+
* - `"html"` → `text/html; charset=utf-8`
|
|
799
|
+
* - `"text"` → `text/plain; charset=utf-8`
|
|
800
|
+
* - `"css"` → `text/css; charset=utf-8`
|
|
801
|
+
* - `"js"` → `application/javascript; charset=utf-8`
|
|
802
|
+
* - `"xml"` → `application/xml; charset=utf-8`
|
|
803
|
+
* - `"csv"` → `text/csv; charset=utf-8`
|
|
804
|
+
* - `"svg"` → `image/svg+xml; charset=utf-8`
|
|
805
|
+
*/
|
|
806
|
+
contentType?: ContentType;
|
|
807
|
+
/** Response headers (use for custom content-types not covered by contentType) */
|
|
808
|
+
headers?: Record<string, string>;
|
|
809
|
+
};
|
|
810
|
+
/**
|
|
811
|
+
* Configuration options extracted from DefineHttpOptions (without onRequest callback)
|
|
812
|
+
*/
|
|
813
|
+
type HttpConfig = LambdaWithPermissions & {
|
|
814
|
+
/** HTTP method for the route */
|
|
815
|
+
method: HttpMethod;
|
|
816
|
+
/** Route path (e.g., "/api/users", "/api/users/{id}") */
|
|
817
|
+
path: string;
|
|
818
|
+
};
|
|
819
|
+
/**
|
|
820
|
+
* Handler function type for HTTP endpoints
|
|
821
|
+
*
|
|
822
|
+
* @typeParam T - Type of the validated request body (from schema function)
|
|
823
|
+
* @typeParam C - Type of the context/dependencies (from context function)
|
|
824
|
+
* @typeParam D - Type of the deps (from deps declaration)
|
|
825
|
+
* @typeParam P - Type of the params (from params declaration)
|
|
826
|
+
*/
|
|
827
|
+
type HttpHandlerFn<T = undefined, C = undefined, D = undefined, P = undefined, S extends string[] | undefined = undefined> = (args: {
|
|
828
|
+
req: HttpRequest;
|
|
829
|
+
} & ([T] extends [undefined] ? {} : {
|
|
830
|
+
data: T;
|
|
831
|
+
}) & ([C] extends [undefined] ? {} : {
|
|
832
|
+
ctx: C;
|
|
833
|
+
}) & ([D] extends [undefined] ? {} : {
|
|
834
|
+
deps: ResolveDeps<D>;
|
|
835
|
+
}) & ([P] extends [undefined] ? {} : {
|
|
836
|
+
params: ResolveParams<P>;
|
|
837
|
+
}) & ([S] extends [undefined] ? {} : {
|
|
838
|
+
readStatic: (path: string) => string;
|
|
839
|
+
})) => Promise<HttpResponse>;
|
|
840
|
+
/**
|
|
841
|
+
* Context factory type — conditional on whether params are declared.
|
|
842
|
+
* Without params: `() => C | Promise<C>`
|
|
843
|
+
* With params: `(args: { params: ResolveParams<P> }) => C | Promise<C>`
|
|
844
|
+
*/
|
|
845
|
+
type ContextFactory<C, P> = [P] extends [undefined] ? () => C | Promise<C> : (args: {
|
|
846
|
+
params: ResolveParams<P & {}>;
|
|
847
|
+
}) => C | Promise<C>;
|
|
848
|
+
/**
|
|
849
|
+
* Options for defining an HTTP endpoint
|
|
850
|
+
*
|
|
851
|
+
* @typeParam T - Type of the validated request body (inferred from schema function)
|
|
852
|
+
* @typeParam C - Type of the context/dependencies returned by context function
|
|
853
|
+
* @typeParam D - Type of the deps (from deps declaration)
|
|
854
|
+
* @typeParam P - Type of the params (from params declaration)
|
|
855
|
+
*/
|
|
856
|
+
type DefineHttpOptions<T = undefined, C = undefined, D extends Record<string, AnyTableHandler> | undefined = undefined, P extends Record<string, AnyParamRef> | undefined = undefined, S extends string[] | undefined = undefined> = HttpConfig & {
|
|
857
|
+
/**
|
|
858
|
+
* Decode/validate function for the request body.
|
|
859
|
+
* Called with the parsed body; should return typed data or throw on validation failure.
|
|
860
|
+
* When provided, the handler receives validated `data` and invalid requests get a 400 response.
|
|
861
|
+
*
|
|
862
|
+
* Works with any validation library:
|
|
863
|
+
* - Effect: `S.decodeUnknownSync(MySchema)`
|
|
864
|
+
* - Zod: `(body) => myZodSchema.parse(body)`
|
|
865
|
+
*/
|
|
866
|
+
schema?: (input: unknown) => T;
|
|
867
|
+
/**
|
|
868
|
+
* Error handler called when schema validation or onRequest throws.
|
|
869
|
+
* Receives the error and request, returns an HttpResponse.
|
|
870
|
+
* If not provided, defaults to 400 for validation errors and 500 for handler errors.
|
|
871
|
+
*/
|
|
872
|
+
onError?: (error: unknown, req: HttpRequest) => HttpResponse;
|
|
873
|
+
/**
|
|
874
|
+
* Factory function to create context/dependencies for the request handler.
|
|
875
|
+
* Called once on cold start, result is cached and reused across invocations.
|
|
876
|
+
* When params are declared, receives resolved params as argument.
|
|
877
|
+
* Supports both sync and async return values.
|
|
878
|
+
*/
|
|
879
|
+
context?: ContextFactory<C, P>;
|
|
880
|
+
/**
|
|
881
|
+
* Dependencies on other handlers (tables, queues, etc.).
|
|
882
|
+
* Typed clients are injected into the handler via the `deps` argument.
|
|
883
|
+
*/
|
|
884
|
+
deps?: D;
|
|
885
|
+
/**
|
|
886
|
+
* SSM Parameter Store parameters.
|
|
887
|
+
* Declare with `param()` helper. Values are fetched and cached at cold start.
|
|
888
|
+
* Typed values are injected into the handler via the `params` argument.
|
|
889
|
+
*/
|
|
890
|
+
params?: P;
|
|
891
|
+
/**
|
|
892
|
+
* Static file glob patterns to bundle into the Lambda ZIP.
|
|
893
|
+
* Files are accessible at runtime via the `readStatic` callback argument.
|
|
894
|
+
*/
|
|
895
|
+
static?: S;
|
|
896
|
+
/** HTTP request handler function */
|
|
897
|
+
onRequest: HttpHandlerFn<T, C, D, P, S>;
|
|
1006
898
|
};
|
|
1007
|
-
|
|
899
|
+
/**
|
|
900
|
+
* Internal handler object created by defineHttp
|
|
901
|
+
* @internal
|
|
902
|
+
*/
|
|
903
|
+
type HttpHandler<T = undefined, C = undefined, D = undefined, P = undefined, S extends string[] | undefined = undefined> = {
|
|
904
|
+
readonly __brand: "effortless-http";
|
|
905
|
+
readonly config: HttpConfig;
|
|
906
|
+
readonly schema?: (input: unknown) => T;
|
|
907
|
+
readonly onError?: (error: unknown, req: HttpRequest) => HttpResponse;
|
|
908
|
+
readonly context?: (...args: any[]) => C | Promise<C>;
|
|
909
|
+
readonly deps?: D;
|
|
910
|
+
readonly params?: P;
|
|
911
|
+
readonly static?: string[];
|
|
912
|
+
readonly onRequest: HttpHandlerFn<T, C, D, P, S>;
|
|
913
|
+
};
|
|
914
|
+
/**
|
|
915
|
+
* Define an HTTP endpoint that creates an API Gateway route + Lambda function
|
|
916
|
+
*
|
|
917
|
+
* @typeParam T - Type of the validated request body (inferred from schema function)
|
|
918
|
+
* @typeParam C - Type of the context/dependencies (inferred from context function)
|
|
919
|
+
* @typeParam D - Type of the deps (from deps declaration)
|
|
920
|
+
* @typeParam P - Type of the params (from params declaration)
|
|
921
|
+
* @param options - Configuration, optional schema, optional context factory, and request handler
|
|
922
|
+
* @returns Handler object used by the deployment system
|
|
923
|
+
*
|
|
924
|
+
* @example Basic GET endpoint
|
|
925
|
+
* ```typescript
|
|
926
|
+
* export const hello = defineHttp({
|
|
927
|
+
* method: "GET",
|
|
928
|
+
* path: "/hello",
|
|
929
|
+
* onRequest: async ({ req }) => ({
|
|
930
|
+
* status: 200,
|
|
931
|
+
* body: { message: "Hello World!" }
|
|
932
|
+
* })
|
|
933
|
+
* });
|
|
934
|
+
* ```
|
|
935
|
+
*
|
|
936
|
+
* @example With SSM parameters
|
|
937
|
+
* ```typescript
|
|
938
|
+
* import { param } from "effortless-aws";
|
|
939
|
+
*
|
|
940
|
+
* export const api = defineHttp({
|
|
941
|
+
* method: "GET",
|
|
942
|
+
* path: "/orders",
|
|
943
|
+
* params: {
|
|
944
|
+
* dbUrl: param("database-url"),
|
|
945
|
+
* },
|
|
946
|
+
* context: async ({ params }) => ({
|
|
947
|
+
* pool: createPool(params.dbUrl),
|
|
948
|
+
* }),
|
|
949
|
+
* onRequest: async ({ req, ctx, params }) => ({
|
|
950
|
+
* status: 200,
|
|
951
|
+
* body: { dbUrl: params.dbUrl }
|
|
952
|
+
* })
|
|
953
|
+
* });
|
|
954
|
+
* ```
|
|
955
|
+
*/
|
|
956
|
+
declare const defineHttp: <T = undefined, C = undefined, D extends Record<string, AnyTableHandler> | undefined = undefined, P extends Record<string, AnyParamRef> | undefined = undefined, S extends string[] | undefined = undefined>(options: DefineHttpOptions<T, C, D, P, S>) => HttpHandler<T, C, D, P, S>;
|
|
1008
957
|
|
|
1009
|
-
export { type AppConfig, type AppHandler, type
|
|
958
|
+
export { type AppConfig, type AppHandler, type ContentType, type DefineFifoQueueOptions, type DefineHttpOptions, type DefineTableOptions, type EffortlessConfig, type FailedRecord, type FifoQueueBatchFn, type FifoQueueConfig, type FifoQueueHandler, type FifoQueueMessage, type FifoQueueMessageFn, type HttpConfig, type HttpHandler, type HttpHandlerFn, type HttpMethod, type HttpRequest, type HttpResponse, type KeyType, type LambdaConfig, type LambdaWithPermissions, type LogLevel, type ParamRef, type QueryParams, type ResolveDeps, type ResolveParams, type StaticSiteConfig, type StaticSiteHandler, type StreamView, type TableBatchCompleteFn, type TableBatchFn, type TableClient, type TableConfig, type TableHandler, type TableKey, type TableRecord, type TableRecordFn, defineApp, defineConfig, defineFifoQueue, defineHttp, defineStaticSite, defineTable, param, typed };
|