@stacksjs/ts-cloud-types 0.1.2 → 0.1.6

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/src/index.ts DELETED
@@ -1,2759 +0,0 @@
1
- /**
2
- * AWS-specific configuration
3
- */
4
- export interface AwsConfig {
5
- /**
6
- * AWS region for deployment
7
- */
8
- region?: string
9
-
10
- /**
11
- * AWS CLI profile to use
12
- */
13
- profile?: string
14
-
15
- /**
16
- * AWS account ID
17
- */
18
- accountId?: string
19
- }
20
-
21
- // Core configuration types
22
- export interface CloudConfig {
23
- project: ProjectConfig
24
- mode?: DeploymentMode // Optional - auto-detected from infrastructure config
25
- environments: Record<string, EnvironmentConfig>
26
- infrastructure?: InfrastructureConfig
27
- sites?: Record<string, SiteConfig>
28
-
29
- /**
30
- * AWS-specific configuration
31
- */
32
- aws?: AwsConfig
33
-
34
- /**
35
- * Feature flags to enable/disable resources conditionally
36
- * Example: { enableCache: true, enableMonitoring: false }
37
- */
38
- features?: Record<string, boolean>
39
-
40
- /**
41
- * Deployment hooks for custom logic
42
- */
43
- hooks?: {
44
- beforeDeploy?: string | ((config: CloudConfig) => Promise<void>)
45
- afterDeploy?: string | ((config: CloudConfig) => Promise<void>)
46
- beforeBuild?: string | ((config: CloudConfig) => Promise<void>)
47
- afterBuild?: string | ((config: CloudConfig) => Promise<void>)
48
- }
49
-
50
- /**
51
- * Cost optimization preset
52
- * Automatically adjusts resource sizes based on budget
53
- */
54
- costPreset?: 'minimal' | 'balanced' | 'performance' | 'custom'
55
-
56
- /**
57
- * Tags applied to all resources
58
- */
59
- tags?: Record<string, string>
60
- }
61
-
62
- export type CloudOptions = Partial<CloudConfig>
63
-
64
- export interface ProjectConfig {
65
- name: string
66
- slug: string
67
- region: string
68
- }
69
-
70
- /**
71
- * Deployment mode (optional)
72
- * @deprecated Mode is now auto-detected from your infrastructure configuration.
73
- * Simply define the resources you need (functions, servers, storage, etc.) and
74
- * ts-cloud will deploy them accordingly. No need to specify a mode.
75
- */
76
- export type DeploymentMode = 'server' | 'serverless' | 'hybrid'
77
-
78
- export type EnvironmentType = 'production' | 'staging' | 'development'
79
-
80
- export interface EnvironmentConfig {
81
- type: EnvironmentType
82
- region?: string
83
- variables?: Record<string, string>
84
- /**
85
- * Custom domain for this environment
86
- * Example: 'example.com' for production, 'staging.example.com' for staging
87
- */
88
- domain?: string
89
- /**
90
- * Environment-specific infrastructure overrides
91
- * Allows different infrastructure per environment
92
- * Example: smaller instances in dev, larger in production
93
- */
94
- infrastructure?: Partial<InfrastructureConfig>
95
- }
96
-
97
- /**
98
- * Network/VPC configuration
99
- */
100
- export interface NetworkConfig {
101
- vpc?: VpcConfig
102
- subnets?: {
103
- public?: number
104
- private?: number
105
- }
106
- natGateway?: boolean | 'single' | 'perAz'
107
- }
108
-
109
- /**
110
- * API Gateway configuration
111
- */
112
- export interface ApiGatewayConfig {
113
- type?: 'REST' | 'HTTP' | 'websocket'
114
- name?: string
115
- description?: string
116
- stageName?: string
117
- cors?: boolean | {
118
- allowOrigins?: string[]
119
- allowMethods?: string[]
120
- allowHeaders?: string[]
121
- maxAge?: number
122
- }
123
- authorization?: 'NONE' | 'IAM' | 'COGNITO' | 'LAMBDA'
124
- throttling?: {
125
- rateLimit?: number
126
- burstLimit?: number
127
- }
128
- customDomain?: {
129
- domain?: string
130
- certificateArn?: string
131
- }
132
- authorizer?: {
133
- type?: string
134
- identitySource?: string
135
- audience?: string[]
136
- }
137
- routes?: Array<{
138
- path?: string
139
- method?: string
140
- integration?: string | { type?: string; service?: string }
141
- authorizer?: string
142
- }> | Record<string, {
143
- path?: string
144
- method?: string
145
- integration?: string | { type?: string; service?: string }
146
- }>
147
- }
148
-
149
- /**
150
- * Messaging (SNS) configuration
151
- */
152
- export interface MessagingConfig {
153
- topics?: Record<string, {
154
- name?: string
155
- displayName?: string
156
- subscriptions?: Array<{
157
- protocol: 'email' | 'sqs' | 'lambda' | 'http' | 'https'
158
- endpoint: string
159
- filterPolicy?: Record<string, string[]>
160
- }>
161
- }>
162
- }
163
-
164
- export interface InfrastructureConfig {
165
- vpc?: VpcConfig
166
-
167
- /**
168
- * Network/VPC configuration
169
- * Defines the network infrastructure including VPC, subnets, and NAT gateways
170
- */
171
- network?: NetworkConfig
172
-
173
- /**
174
- * Compute/EC2 configuration
175
- * Defines the EC2 instances running your Stacks/Bun application
176
- *
177
- * @example
178
- * // Single instance (no load balancer needed)
179
- * compute: {
180
- * instances: 1,
181
- * instanceType: 't3.micro',
182
- * }
183
- *
184
- * @example
185
- * // Multiple instances (load balancer auto-enabled)
186
- * compute: {
187
- * instances: 3,
188
- * instanceType: 't3.small',
189
- * autoScaling: {
190
- * min: 2,
191
- * max: 10,
192
- * scaleUpThreshold: 70,
193
- * },
194
- * }
195
- */
196
- compute?: ComputeConfig
197
-
198
- storage?: Record<string, StorageItemConfig & ResourceConditions>
199
- functions?: Record<string, FunctionConfig & ResourceConditions>
200
- /** @deprecated Use `compute` instead for EC2 configuration */
201
- servers?: Record<string, ServerItemConfig & ResourceConditions>
202
- databases?: Record<string, DatabaseItemConfig & ResourceConditions>
203
- cache?: CacheConfig
204
- cdn?: Record<string, CdnItemConfig & ResourceConditions> | CdnItemConfig
205
- /**
206
- * Elastic File System (EFS) configuration
207
- * For shared file storage across multiple instances
208
- */
209
- fileSystem?: Record<string, FileSystemItemConfig>
210
-
211
- /**
212
- * API Gateway configuration
213
- * Defines the API Gateway for routing HTTP requests to Lambda functions
214
- */
215
- apiGateway?: ApiGatewayConfig
216
-
217
- /**
218
- * Messaging (SNS) configuration
219
- * Defines SNS topics for pub/sub messaging patterns
220
- */
221
- messaging?: MessagingConfig
222
-
223
- /**
224
- * Queue (SQS) configuration
225
- * Defines message queues for async processing, background jobs, and event-driven architectures
226
- *
227
- * @example
228
- * queues: {
229
- * // Standard queue for background jobs
230
- * jobs: {
231
- * visibilityTimeout: 120,
232
- * deadLetterQueue: true,
233
- * },
234
- * // FIFO queue for ordered processing
235
- * orders: {
236
- * fifo: true,
237
- * contentBasedDeduplication: true,
238
- * },
239
- * // High-throughput events queue
240
- * events: {
241
- * receiveMessageWaitTime: 20,
242
- * },
243
- * }
244
- */
245
- queues?: Record<string, QueueItemConfig & ResourceConditions>
246
-
247
- /**
248
- * Realtime (WebSocket) configuration
249
- * Laravel Echo / Pusher-compatible broadcasting for Stacks.js
250
- *
251
- * @example
252
- * realtime: {
253
- * enabled: true,
254
- * channels: { public: true, private: true, presence: true },
255
- * auth: { functionName: 'authorizeChannel' },
256
- * }
257
- *
258
- * @example Using presets
259
- * realtime: RealtimePresets.production
260
- */
261
- realtime?: RealtimeConfig
262
-
263
- dns?: DnsConfig
264
- security?: SecurityConfig
265
- monitoring?: MonitoringConfig
266
- api?: ApiConfig
267
- loadBalancer?: LoadBalancerConfig
268
- ssl?: SslConfig
269
- streaming?: Record<string, {
270
- name?: string
271
- shardCount?: number
272
- retentionPeriod?: number
273
- encryption?: boolean | string
274
- }>
275
- machineLearning?: {
276
- sagemakerEndpoint?: string
277
- modelBucket?: string
278
- sagemaker?: {
279
- endpointName?: string
280
- instanceType?: string
281
- endpoints?: Array<{
282
- name?: string
283
- modelName?: string
284
- modelS3Path?: string
285
- instanceType?: string
286
- instanceCount?: number
287
- initialInstanceCount?: number
288
- autoScaling?: {
289
- minInstances?: number
290
- maxInstances?: number
291
- targetInvocationsPerInstance?: number
292
- }
293
- }>
294
- trainingJobs?: Array<{
295
- name?: string
296
- algorithmSpecification?: {
297
- trainingImage?: string
298
- trainingInputMode?: string
299
- }
300
- instanceType?: string
301
- instanceCount?: number
302
- volumeSizeInGB?: number
303
- maxRuntimeInSeconds?: number
304
- }>
305
- }
306
- }
307
- analytics?: {
308
- enabled?: boolean
309
- firehose?: Record<string, {
310
- name?: string
311
- destination?: string
312
- bufferSize?: number
313
- bufferInterval?: number
314
- }>
315
- athena?: {
316
- database?: string
317
- workgroup?: string
318
- outputLocation?: string
319
- outputBucket?: string
320
- tables?: Array<{
321
- name?: string
322
- location?: string
323
- format?: string
324
- partitionKeys?: string[]
325
- }>
326
- }
327
- glue?: {
328
- crawlers?: Array<{
329
- name?: string
330
- databaseName?: string
331
- s3Targets?: string[]
332
- schedule?: string
333
- }>
334
- jobs?: Array<{
335
- name?: string
336
- scriptLocation?: string
337
- role?: string
338
- maxCapacity?: number
339
- timeout?: number
340
- }>
341
- }
342
- }
343
- workflow?: {
344
- pipelines?: Array<{
345
- name?: string
346
- type?: 'stepFunctions' | string
347
- definition?: Record<string, unknown>
348
- schedule?: string
349
- }>
350
- }
351
- }
352
-
353
- /**
354
- * Conditions that determine if a resource should be deployed
355
- */
356
- export interface ResourceConditions {
357
- /**
358
- * Only deploy in these environments
359
- * Example: ['production', 'staging']
360
- */
361
- environments?: EnvironmentType[]
362
-
363
- /**
364
- * Only deploy if these features are enabled
365
- * Example: ['enableDatabase', 'enableCache']
366
- */
367
- requiresFeatures?: string[]
368
-
369
- /**
370
- * Only deploy in these regions
371
- */
372
- regions?: string[]
373
-
374
- /**
375
- * Custom condition function
376
- */
377
- condition?: (config: CloudConfig, env: EnvironmentType) => boolean
378
- }
379
-
380
- export interface SiteConfig {
381
- root: string
382
- path: string
383
- domain?: string
384
- }
385
-
386
- export interface VpcConfig {
387
- cidr?: string
388
- zones?: number
389
- availabilityZones?: number // Alias for zones
390
- natGateway?: boolean
391
- natGateways?: number | boolean
392
- }
393
-
394
- export interface StorageConfig {
395
- buckets?: BucketConfig[]
396
- }
397
-
398
- export interface BucketConfig {
399
- name: string
400
- public?: boolean
401
- versioning?: boolean
402
- website?: boolean
403
- encryption?: boolean
404
- }
405
-
406
- export interface DatabaseConfig {
407
- type?: 'rds' | 'dynamodb'
408
- engine?: 'postgres' | 'mysql'
409
- instanceType?: string
410
- }
411
-
412
- export interface CacheConfig {
413
- type?: 'redis' | 'memcached'
414
- nodeType?: string
415
- /**
416
- * Redis-specific configuration
417
- */
418
- redis?: {
419
- nodeType?: string
420
- numCacheNodes?: number
421
- engine?: string
422
- engineVersion?: string
423
- port?: number
424
- parameterGroup?: Record<string, string>
425
- snapshotRetentionLimit?: number
426
- snapshotWindow?: string
427
- automaticFailoverEnabled?: boolean
428
- }
429
- /**
430
- * ElastiCache configuration
431
- */
432
- elasticache?: {
433
- nodeType?: string
434
- numCacheNodes?: number
435
- engine?: string
436
- engineVersion?: string
437
- }
438
- }
439
-
440
- export interface CdnConfig {
441
- enabled?: boolean
442
- customDomain?: string
443
- certificateArn?: string
444
- }
445
-
446
- export interface DnsConfig {
447
- domain?: string
448
- hostedZoneId?: string
449
- }
450
-
451
- export interface SecurityConfig {
452
- waf?: WafConfig
453
- kms?: boolean
454
- /**
455
- * SSL/TLS Certificate configuration
456
- */
457
- certificate?: {
458
- domain: string
459
- subdomains?: string[]
460
- validationMethod?: 'DNS' | 'EMAIL'
461
- }
462
- /**
463
- * Security groups configuration
464
- */
465
- securityGroups?: Record<string, {
466
- ingress?: Array<{
467
- port: number
468
- protocol: string
469
- cidr?: string
470
- source?: string
471
- }>
472
- egress?: Array<{
473
- port: number
474
- protocol: string
475
- cidr?: string
476
- destination?: string
477
- }>
478
- }>
479
- }
480
-
481
- export interface WafConfig {
482
- enabled?: boolean
483
- blockCountries?: string[]
484
- blockIps?: string[]
485
- rateLimit?: number
486
- /**
487
- * WAF rules to enable
488
- * @example ['rateLimit', 'sqlInjection', 'xss']
489
- */
490
- rules?: string[]
491
- }
492
-
493
- export interface MonitoringConfig {
494
- alarms?: Record<string, AlarmItemConfig> | AlarmItemConfig[]
495
- dashboards?: boolean
496
- /**
497
- * Dashboard configuration
498
- */
499
- dashboard?: {
500
- name?: string
501
- widgets?: Array<{
502
- type?: string
503
- metrics?: string[] | Array<{
504
- service?: string
505
- metric?: string
506
- }>
507
- }>
508
- }
509
- /**
510
- * Log configuration
511
- */
512
- logs?: {
513
- retention?: number
514
- groups?: string[]
515
- }
516
- }
517
-
518
- export interface AlarmConfig {
519
- name: string
520
- metric: string
521
- threshold: number
522
- }
523
-
524
- export interface AlarmItemConfig {
525
- /**
526
- * Name of the alarm (optional, auto-generated if not provided)
527
- */
528
- name?: string
529
- /**
530
- * Metric name (short form)
531
- */
532
- metric?: string
533
- metricName?: string
534
- namespace?: string
535
- threshold: number
536
- comparisonOperator?: string
537
- /**
538
- * Period in seconds for metric aggregation
539
- */
540
- period?: number
541
- /**
542
- * Number of periods to evaluate
543
- */
544
- evaluationPeriods?: number
545
- /**
546
- * Service name for service-specific alarms
547
- */
548
- service?: string
549
- }
550
-
551
- export interface StorageItemConfig {
552
- /**
553
- * Make bucket publicly accessible
554
- */
555
- public?: boolean
556
- versioning?: boolean
557
- encryption?: boolean
558
- encrypted?: boolean // Alias for encryption (for EFS compatibility)
559
- website?: boolean | {
560
- indexDocument?: string
561
- errorDocument?: string
562
- }
563
- /**
564
- * Storage type (for special storage like EFS)
565
- */
566
- type?: 'efs' | 's3'
567
- /**
568
- * Enable Intelligent Tiering for cost optimization
569
- */
570
- intelligentTiering?: boolean
571
- /**
572
- * CORS configuration
573
- */
574
- cors?: Array<{
575
- allowedOrigins?: string[]
576
- allowedMethods?: string[]
577
- allowedHeaders?: string[]
578
- maxAge?: number
579
- }>
580
- /**
581
- * Lifecycle rules for automatic transitions/deletions
582
- */
583
- lifecycleRules?: Array<{
584
- id?: string
585
- enabled?: boolean
586
- expirationDays?: number
587
- transitions?: Array<{
588
- days?: number
589
- storageClass?: string
590
- }>
591
- }>
592
- /**
593
- * Performance mode (for EFS)
594
- */
595
- performanceMode?: string
596
- /**
597
- * Throughput mode (for EFS)
598
- */
599
- throughputMode?: string
600
- /**
601
- * Lifecycle policy (for EFS)
602
- */
603
- lifecyclePolicy?: {
604
- transitionToIA?: number
605
- }
606
- }
607
-
608
- export interface FunctionConfig {
609
- handler?: string
610
- runtime?: string
611
- code?: string
612
- timeout?: number
613
- memorySize?: number
614
- memory?: number // Alias for memorySize
615
- events?: Array<{
616
- type?: string
617
- path?: string
618
- method?: string
619
- queueName?: string
620
- streamName?: string
621
- tableName?: string
622
- expression?: string
623
- batchSize?: number
624
- startingPosition?: string
625
- parallelizationFactor?: number
626
- bucket?: string
627
- prefix?: string
628
- suffix?: string
629
- }>
630
- environment?: Record<string, string>
631
- }
632
-
633
- /**
634
- * Elastic File System (EFS) configuration
635
- */
636
- export interface FileSystemItemConfig {
637
- /**
638
- * Performance mode
639
- */
640
- performanceMode?: 'generalPurpose' | 'maxIO' | string
641
- /**
642
- * Throughput mode
643
- */
644
- throughputMode?: 'bursting' | 'provisioned' | string
645
- /**
646
- * Enable encryption
647
- */
648
- encrypted?: boolean
649
- /**
650
- * Lifecycle policy
651
- */
652
- lifecyclePolicy?: {
653
- transitionToIA?: number
654
- }
655
- /**
656
- * Mount path
657
- */
658
- mountPath?: string
659
- }
660
-
661
- /**
662
- * Instance size presets
663
- * Provider-agnostic sizing that maps to appropriate instance types
664
- */
665
- export type InstanceSize =
666
- | 'nano' // ~0.5 vCPU, 0.5GB RAM
667
- | 'micro' // ~1 vCPU, 1GB RAM
668
- | 'small' // ~1 vCPU, 2GB RAM
669
- | 'medium' // ~2 vCPU, 4GB RAM
670
- | 'large' // ~2 vCPU, 8GB RAM
671
- | 'xlarge' // ~4 vCPU, 16GB RAM
672
- | '2xlarge' // ~8 vCPU, 32GB RAM
673
- | (string & {}) // Allow provider-specific types like 't3.micro'
674
-
675
- /**
676
- * Server/VM Instance Configuration
677
- */
678
- export interface ServerItemConfig {
679
- /**
680
- * Instance size or provider-specific type
681
- * @example 'small', 'medium', 'large' or 't3.micro'
682
- * @default 'micro'
683
- */
684
- size?: InstanceSize
685
-
686
- /**
687
- * Custom machine image (optional)
688
- * If not specified, uses the provider's default Linux image
689
- */
690
- image?: string
691
-
692
- /**
693
- * Custom startup script
694
- */
695
- startupScript?: string
696
- }
697
-
698
- /**
699
- * Instance configuration for mixed instance fleets
700
- */
701
- export interface InstanceConfig {
702
- /**
703
- * Instance size or provider-specific type
704
- * @example 'small', 'medium', 'large' or 't3.micro'
705
- */
706
- size: InstanceSize
707
-
708
- /**
709
- * Weight for this instance type in auto scaling
710
- * Higher weight = more capacity per instance
711
- * @default 1
712
- */
713
- weight?: number
714
-
715
- /**
716
- * Use spot/preemptible instances for cost savings
717
- * @default false
718
- */
719
- spot?: boolean
720
-
721
- /**
722
- * Maximum price for spot instances (per hour)
723
- * Only used when spot: true
724
- */
725
- maxPrice?: string
726
- }
727
-
728
- /**
729
- * Compute Configuration
730
- * Defines the virtual machines/instances for your application
731
- *
732
- * @example Single instance
733
- * compute: {
734
- * instances: 1,
735
- * size: 'small',
736
- * }
737
- *
738
- * @example Multiple instances (auto-enables load balancer)
739
- * compute: {
740
- * instances: 3,
741
- * size: 'medium',
742
- * autoScaling: { min: 2, max: 10 },
743
- * }
744
- *
745
- * @example Mixed instance fleet for cost optimization
746
- * compute: {
747
- * instances: 3,
748
- * fleet: [
749
- * { size: 'small', weight: 1 },
750
- * { size: 'medium', weight: 2 },
751
- * { size: 'small', weight: 1, spot: true },
752
- * ],
753
- * }
754
- */
755
- export interface ComputeConfig {
756
- /**
757
- * Compute mode: 'server' for EC2, 'serverless' for Fargate/Lambda
758
- */
759
- mode?: 'server' | 'serverless'
760
-
761
- /**
762
- * Number of instances to run
763
- * When > 1, load balancer is automatically enabled
764
- * @default 1
765
- */
766
- instances?: number
767
-
768
- /**
769
- * Instance size (simple configuration)
770
- * Use this OR fleet, not both
771
- * @default 'micro'
772
- */
773
- size?: InstanceSize
774
-
775
- /**
776
- * Mixed instance fleet for cost optimization
777
- * Allows combining different sizes and spot instances
778
- *
779
- * @example
780
- * fleet: [
781
- * { size: 'small', weight: 1 },
782
- * { size: 'medium', weight: 2 },
783
- * { size: 'small', weight: 1, spot: true },
784
- * ]
785
- */
786
- fleet?: InstanceConfig[]
787
-
788
- /**
789
- * Custom machine image (optional)
790
- * If not specified, uses the provider's default Linux image
791
- */
792
- image?: string
793
-
794
- /**
795
- * Server mode (EC2) configuration
796
- */
797
- server?: {
798
- instanceType?: string
799
- ami?: string
800
- keyPair?: string
801
- autoScaling?: {
802
- min?: number
803
- max?: number
804
- desired?: number
805
- targetCPU?: number
806
- scaleUpCooldown?: number
807
- scaleDownCooldown?: number
808
- }
809
- loadBalancer?: {
810
- type?: string
811
- healthCheck?: {
812
- path?: string
813
- interval?: number
814
- timeout?: number
815
- healthyThreshold?: number
816
- unhealthyThreshold?: number
817
- }
818
- stickySession?: {
819
- enabled?: boolean
820
- duration?: number
821
- }
822
- }
823
- userData?: string | {
824
- packages?: string[]
825
- commands?: string[]
826
- }
827
- }
828
-
829
- /**
830
- * Serverless configuration (ECS/Lambda)
831
- */
832
- serverless?: {
833
- cpu?: number
834
- memory?: number
835
- desiredCount?: number
836
- }
837
-
838
- /**
839
- * Fargate configuration
840
- */
841
- fargate?: {
842
- taskDefinition?: {
843
- cpu?: string
844
- memory?: string
845
- containerDefinitions?: Array<{
846
- name?: string
847
- image?: string
848
- portMappings?: Array<{
849
- containerPort?: number
850
- }>
851
- environment?: unknown[]
852
- secrets?: unknown[]
853
- }>
854
- }
855
- service?: {
856
- desiredCount?: number
857
- healthCheck?: {
858
- path?: string
859
- interval?: number
860
- timeout?: number
861
- healthyThreshold?: number
862
- unhealthyThreshold?: number
863
- }
864
- serviceDiscovery?: {
865
- enabled?: boolean
866
- namespace?: string
867
- }
868
- autoScaling?: {
869
- min?: number
870
- max?: number
871
- targetCPU?: number
872
- targetMemory?: number
873
- }
874
- }
875
- loadBalancer?: {
876
- type?: string
877
- customDomain?: {
878
- domain?: string
879
- certificateArn?: string
880
- }
881
- }
882
- }
883
-
884
- /**
885
- * Microservices configuration
886
- */
887
- services?: Array<{
888
- name: string
889
- type?: string
890
- taskDefinition?: {
891
- cpu?: string
892
- memory?: string
893
- containerDefinitions?: Array<{
894
- name?: string
895
- image?: string
896
- portMappings?: Array<{
897
- containerPort?: number
898
- }>
899
- healthCheck?: {
900
- command?: string[]
901
- interval?: number
902
- timeout?: number
903
- retries?: number
904
- }
905
- }>
906
- }
907
- service?: {
908
- desiredCount?: number
909
- serviceDiscovery?: {
910
- enabled?: boolean
911
- namespace?: string
912
- }
913
- autoScaling?: {
914
- min?: number
915
- max?: number
916
- targetCPU?: number
917
- }
918
- }
919
- }>
920
-
921
- /**
922
- * Auto Scaling configuration
923
- */
924
- autoScaling?: {
925
- /** Minimum number of instances @default 1 */
926
- min?: number
927
- /** Maximum number of instances @default instances value */
928
- max?: number
929
- /** Desired number of instances @default instances value */
930
- desired?: number
931
- /** CPU threshold to scale up (%) @default 70 */
932
- scaleUpThreshold?: number
933
- /** CPU threshold to scale down (%) @default 30 */
934
- scaleDownThreshold?: number
935
- /** Cooldown in seconds @default 300 */
936
- cooldown?: number
937
- }
938
-
939
- /**
940
- * Root disk configuration
941
- */
942
- disk?: {
943
- /** Size in GB @default 20 */
944
- size?: number
945
- /** Disk type @default 'ssd' */
946
- type?: 'standard' | 'ssd' | 'premium'
947
- /** Enable encryption @default true */
948
- encrypted?: boolean
949
- }
950
-
951
- /**
952
- * SSH key name for instance access
953
- */
954
- sshKey?: string
955
-
956
- /**
957
- * Enable detailed monitoring
958
- * @default false
959
- */
960
- monitoring?: boolean
961
-
962
- /**
963
- * Spot/preemptible instance settings (when using fleet)
964
- */
965
- spotConfig?: {
966
- /** Base capacity that must be on-demand @default 1 */
967
- baseCapacity?: number
968
- /** % of instances above base that are on-demand @default 100 */
969
- onDemandPercentage?: number
970
- /** Allocation strategy @default 'capacity-optimized' */
971
- strategy?: 'lowest-price' | 'capacity-optimized'
972
- }
973
- }
974
-
975
- export interface DatabaseItemConfig {
976
- engine?: 'dynamodb' | 'postgres' | 'mysql'
977
- partitionKey?: string | { name: string; type: string }
978
- sortKey?: string | { name: string; type: string }
979
- username?: string
980
- password?: string
981
- storage?: number
982
- instanceClass?: string
983
- version?: string
984
- allocatedStorage?: number
985
- maxAllocatedStorage?: number
986
- multiAZ?: boolean
987
- backupRetentionDays?: number
988
- preferredBackupWindow?: string
989
- preferredMaintenanceWindow?: string
990
- deletionProtection?: boolean
991
- streamEnabled?: boolean
992
- pointInTimeRecovery?: boolean
993
- billingMode?: string
994
- parameters?: Record<string, string | number>
995
- databaseName?: string
996
- enablePerformanceInsights?: boolean
997
- performanceInsightsRetention?: number
998
- tables?: Record<string, {
999
- name?: string
1000
- partitionKey?: string | { name: string; type: string }
1001
- sortKey?: string | { name: string; type: string }
1002
- billing?: string
1003
- billingMode?: string
1004
- streamEnabled?: boolean
1005
- pointInTimeRecovery?: boolean
1006
- globalSecondaryIndexes?: Array<{
1007
- name: string
1008
- partitionKey: { name: string; type: string }
1009
- sortKey?: { name: string; type: string }
1010
- projection: string
1011
- }>
1012
- }>
1013
- }
1014
-
1015
- export interface CdnItemConfig {
1016
- origin?: string
1017
- customDomain?: string | {
1018
- domain: string
1019
- certificateArn?: string
1020
- }
1021
- certificateArn?: string
1022
- /**
1023
- * Custom domain configuration
1024
- */
1025
- domain?: string
1026
- /**
1027
- * Enable CDN
1028
- */
1029
- enabled?: boolean
1030
- /**
1031
- * Cache policy configuration
1032
- */
1033
- cachePolicy?: {
1034
- minTTL?: number
1035
- defaultTTL?: number
1036
- maxTTL?: number
1037
- }
1038
- /**
1039
- * TTL settings
1040
- */
1041
- minTTL?: number
1042
- defaultTTL?: number
1043
- maxTTL?: number
1044
- /**
1045
- * Enable compression
1046
- */
1047
- compress?: boolean
1048
- /**
1049
- * Enable HTTP/3
1050
- */
1051
- http3?: boolean
1052
- /**
1053
- * Custom error pages
1054
- */
1055
- errorPages?: Record<number | string, string>
1056
- /**
1057
- * Origins configuration
1058
- */
1059
- origins?: Array<{
1060
- type?: string
1061
- pathPattern?: string
1062
- domainName?: string
1063
- originId?: string
1064
- }>
1065
- /**
1066
- * Edge functions for Lambda@Edge
1067
- */
1068
- edgeFunctions?: Array<{
1069
- eventType?: string
1070
- functionArn?: string
1071
- name?: string
1072
- }>
1073
- }
1074
-
1075
- /**
1076
- * Lambda trigger configuration for SQS queues
1077
- */
1078
- export interface QueueLambdaTrigger {
1079
- /**
1080
- * Name of the Lambda function to trigger (references functions config)
1081
- * @example 'processOrders' - references infrastructure.functions.processOrders
1082
- */
1083
- functionName: string
1084
-
1085
- /**
1086
- * Number of messages to process in each batch
1087
- * @default 10
1088
- */
1089
- batchSize?: number
1090
-
1091
- /**
1092
- * Maximum time to gather messages before invoking (0-300 seconds)
1093
- * Helps reduce Lambda invocations for low-traffic queues
1094
- * @default 0
1095
- */
1096
- batchWindow?: number
1097
-
1098
- /**
1099
- * Enable partial batch responses (report individual failures)
1100
- * @default true
1101
- */
1102
- reportBatchItemFailures?: boolean
1103
-
1104
- /**
1105
- * Maximum concurrency for Lambda invocations (2-1000)
1106
- * Limits how many concurrent Lambda instances process this queue
1107
- */
1108
- maxConcurrency?: number
1109
-
1110
- /**
1111
- * Filter pattern to selectively process messages
1112
- * @example { body: { type: ['order'] } }
1113
- */
1114
- filterPattern?: Record<string, unknown>
1115
- }
1116
-
1117
- /**
1118
- * CloudWatch alarm configuration for SQS queues
1119
- */
1120
- export interface QueueAlarms {
1121
- /**
1122
- * Enable all default alarms
1123
- * @default false
1124
- */
1125
- enabled?: boolean
1126
-
1127
- /**
1128
- * Alarm when queue depth exceeds this threshold
1129
- * @default 1000
1130
- */
1131
- queueDepthThreshold?: number
1132
-
1133
- /**
1134
- * Alarm when oldest message age exceeds this (in seconds)
1135
- * @default 3600 (1 hour)
1136
- */
1137
- messageAgeThreshold?: number
1138
-
1139
- /**
1140
- * Alarm when DLQ has any messages
1141
- * @default true when deadLetterQueue is enabled
1142
- */
1143
- dlqAlarm?: boolean
1144
-
1145
- /**
1146
- * SNS topic ARN for alarm notifications
1147
- */
1148
- notificationTopicArn?: string
1149
-
1150
- /**
1151
- * Email addresses to notify (creates SNS topic automatically)
1152
- */
1153
- notificationEmails?: string[]
1154
- }
1155
-
1156
- /**
1157
- * SNS subscription configuration for SQS queues
1158
- */
1159
- export interface QueueSnsSubscription {
1160
- /**
1161
- * SNS topic ARN to subscribe to
1162
- */
1163
- topicArn?: string
1164
-
1165
- /**
1166
- * SNS topic name (references infrastructure or creates new)
1167
- */
1168
- topicName?: string
1169
-
1170
- /**
1171
- * Filter policy for selective message delivery
1172
- * @example { eventType: ['order.created', 'order.updated'] }
1173
- */
1174
- filterPolicy?: Record<string, string[]>
1175
-
1176
- /**
1177
- * Apply filter to message attributes (default) or body
1178
- * @default 'MessageAttributes'
1179
- */
1180
- filterPolicyScope?: 'MessageAttributes' | 'MessageBody'
1181
-
1182
- /**
1183
- * Enable raw message delivery (no SNS envelope)
1184
- * @default false
1185
- */
1186
- rawMessageDelivery?: boolean
1187
- }
1188
-
1189
- /**
1190
- * Queue (SQS) Configuration
1191
- * Defines message queue settings for async processing
1192
- *
1193
- * @example Standard queue with Lambda trigger
1194
- * queues: {
1195
- * orders: {
1196
- * visibilityTimeout: 60,
1197
- * deadLetterQueue: true,
1198
- * trigger: {
1199
- * functionName: 'processOrders',
1200
- * batchSize: 10,
1201
- * },
1202
- * }
1203
- * }
1204
- *
1205
- * @example FIFO queue with alarms
1206
- * queues: {
1207
- * transactions: {
1208
- * fifo: true,
1209
- * contentBasedDeduplication: true,
1210
- * alarms: {
1211
- * enabled: true,
1212
- * queueDepthThreshold: 500,
1213
- * notificationEmails: ['ops@example.com'],
1214
- * },
1215
- * }
1216
- * }
1217
- *
1218
- * @example Queue subscribed to SNS topic
1219
- * queues: {
1220
- * notifications: {
1221
- * subscribe: {
1222
- * topicArn: 'arn:aws:sns:us-east-1:123456789:events',
1223
- * filterPolicy: { eventType: ['user.created'] },
1224
- * },
1225
- * }
1226
- * }
1227
- */
1228
- export interface QueueItemConfig {
1229
- /**
1230
- * Enable FIFO (First-In-First-Out) queue
1231
- * FIFO queues guarantee message ordering and exactly-once processing
1232
- * @default false
1233
- */
1234
- fifo?: boolean
1235
-
1236
- /**
1237
- * Time (in seconds) a message is invisible after being received
1238
- * Should be long enough for your consumer to process the message
1239
- * @default 30
1240
- */
1241
- visibilityTimeout?: number
1242
-
1243
- /**
1244
- * Time (in seconds) messages are retained in the queue
1245
- * Valid range: 60 (1 minute) to 1209600 (14 days)
1246
- * @default 345600 (4 days)
1247
- */
1248
- messageRetentionPeriod?: number
1249
-
1250
- /**
1251
- * Time (in seconds) to delay message delivery
1252
- * Useful for scheduling or rate limiting
1253
- * Valid range: 0 to 900 (15 minutes)
1254
- * @default 0
1255
- */
1256
- delaySeconds?: number
1257
-
1258
- /**
1259
- * Maximum message size in bytes
1260
- * Valid range: 1024 (1 KB) to 262144 (256 KB)
1261
- * @default 262144 (256 KB)
1262
- */
1263
- maxMessageSize?: number
1264
-
1265
- /**
1266
- * Time (in seconds) to wait for messages when polling
1267
- * Use 1-20 for long polling (recommended), 0 for short polling
1268
- * Long polling reduces costs and improves responsiveness
1269
- * @default 0
1270
- */
1271
- receiveMessageWaitTime?: number
1272
-
1273
- /**
1274
- * Enable dead letter queue for failed messages
1275
- * Messages that fail processing will be moved to a DLQ
1276
- * @default false
1277
- */
1278
- deadLetterQueue?: boolean
1279
-
1280
- /**
1281
- * Number of times a message can be received before going to DLQ
1282
- * Only used when deadLetterQueue is true
1283
- * @default 3
1284
- */
1285
- maxReceiveCount?: number
1286
-
1287
- /**
1288
- * Enable content-based deduplication (FIFO queues only)
1289
- * Uses SHA-256 hash of message body as deduplication ID
1290
- * @default false
1291
- */
1292
- contentBasedDeduplication?: boolean
1293
-
1294
- /**
1295
- * Enable server-side encryption
1296
- * @default true
1297
- */
1298
- encrypted?: boolean
1299
-
1300
- /**
1301
- * Custom KMS key ID for encryption
1302
- * If not specified, uses AWS managed key
1303
- */
1304
- kmsKeyId?: string
1305
-
1306
- /**
1307
- * Lambda function trigger configuration
1308
- * Automatically invokes a Lambda when messages arrive
1309
- *
1310
- * @example
1311
- * trigger: {
1312
- * functionName: 'processOrders',
1313
- * batchSize: 10,
1314
- * batchWindow: 30,
1315
- * }
1316
- */
1317
- trigger?: QueueLambdaTrigger
1318
-
1319
- /**
1320
- * CloudWatch alarms for queue monitoring
1321
- * Creates alarms for queue depth, message age, and DLQ
1322
- *
1323
- * @example
1324
- * alarms: {
1325
- * enabled: true,
1326
- * queueDepthThreshold: 500,
1327
- * notificationEmails: ['ops@example.com'],
1328
- * }
1329
- */
1330
- alarms?: QueueAlarms
1331
-
1332
- /**
1333
- * Subscribe this queue to an SNS topic
1334
- * Enables fan-out patterns where one message reaches multiple queues
1335
- *
1336
- * @example
1337
- * subscribe: {
1338
- * topicArn: 'arn:aws:sns:us-east-1:123456789:events',
1339
- * filterPolicy: { eventType: ['order.created'] },
1340
- * }
1341
- */
1342
- subscribe?: QueueSnsSubscription
1343
-
1344
- /**
1345
- * Custom tags for the queue
1346
- * Useful for cost allocation and organization
1347
- */
1348
- tags?: Record<string, string>
1349
- }
1350
-
1351
- /**
1352
- * Queue configuration presets for common use cases
1353
- * Use these to quickly configure queues with sensible defaults
1354
- *
1355
- * @example Basic usage
1356
- * import { QueuePresets } from '@stacksjs/ts-cloud-types'
1357
- *
1358
- * queues: {
1359
- * jobs: QueuePresets.backgroundJobs,
1360
- * orders: QueuePresets.fifo,
1361
- * events: QueuePresets.highThroughput,
1362
- * }
1363
- *
1364
- * @example With Lambda trigger
1365
- * queues: {
1366
- * orders: {
1367
- * ...QueuePresets.backgroundJobs,
1368
- * trigger: { functionName: 'processOrders' },
1369
- * },
1370
- * }
1371
- *
1372
- * @example With monitoring
1373
- * queues: {
1374
- * critical: {
1375
- * ...QueuePresets.monitored,
1376
- * alarms: {
1377
- * ...QueuePresets.monitored.alarms,
1378
- * notificationEmails: ['ops@example.com'],
1379
- * },
1380
- * },
1381
- * }
1382
- */
1383
- export const QueuePresets: {
1384
- backgroundJobs: QueueItemConfig
1385
- fifo: QueueItemConfig
1386
- highThroughput: QueueItemConfig
1387
- delayed: QueueItemConfig
1388
- longRunning: QueueItemConfig
1389
- monitored: QueueItemConfig
1390
- lambdaOptimized: QueueItemConfig
1391
- fanOut: QueueItemConfig
1392
- } = {
1393
- /**
1394
- * Background job queue with dead letter support
1395
- * Good for: async tasks, email sending, file processing
1396
- */
1397
- backgroundJobs: {
1398
- visibilityTimeout: 120,
1399
- messageRetentionPeriod: 604800, // 7 days
1400
- deadLetterQueue: true,
1401
- maxReceiveCount: 3,
1402
- encrypted: true,
1403
- },
1404
-
1405
- /**
1406
- * FIFO queue for ordered, exactly-once processing
1407
- * Good for: financial transactions, order processing
1408
- */
1409
- fifo: {
1410
- fifo: true,
1411
- contentBasedDeduplication: true,
1412
- visibilityTimeout: 30,
1413
- encrypted: true,
1414
- },
1415
-
1416
- /**
1417
- * High-throughput queue with long polling
1418
- * Good for: event streaming, real-time processing
1419
- */
1420
- highThroughput: {
1421
- visibilityTimeout: 30,
1422
- receiveMessageWaitTime: 20,
1423
- encrypted: true,
1424
- },
1425
-
1426
- /**
1427
- * Delayed queue for scheduled messages
1428
- * Good for: scheduled tasks, rate limiting
1429
- */
1430
- delayed: {
1431
- delaySeconds: 60,
1432
- visibilityTimeout: 60,
1433
- encrypted: true,
1434
- },
1435
-
1436
- /**
1437
- * Long-running task queue
1438
- * Good for: video processing, ML inference, batch jobs
1439
- */
1440
- longRunning: {
1441
- visibilityTimeout: 900, // 15 minutes
1442
- messageRetentionPeriod: 1209600, // 14 days
1443
- deadLetterQueue: true,
1444
- maxReceiveCount: 2,
1445
- encrypted: true,
1446
- },
1447
-
1448
- /**
1449
- * Production queue with full monitoring
1450
- * Good for: critical workloads requiring observability
1451
- */
1452
- monitored: {
1453
- visibilityTimeout: 60,
1454
- messageRetentionPeriod: 604800, // 7 days
1455
- deadLetterQueue: true,
1456
- maxReceiveCount: 3,
1457
- encrypted: true,
1458
- alarms: {
1459
- enabled: true,
1460
- queueDepthThreshold: 1000,
1461
- messageAgeThreshold: 3600,
1462
- dlqAlarm: true,
1463
- },
1464
- },
1465
-
1466
- /**
1467
- * Event-driven queue optimized for Lambda processing
1468
- * Good for: serverless event processing, webhooks
1469
- */
1470
- lambdaOptimized: {
1471
- visibilityTimeout: 360, // 6x default Lambda timeout
1472
- receiveMessageWaitTime: 20,
1473
- deadLetterQueue: true,
1474
- maxReceiveCount: 3,
1475
- encrypted: true,
1476
- },
1477
-
1478
- /**
1479
- * Fan-out queue for SNS integration
1480
- * Good for: pub/sub patterns, multi-consumer scenarios
1481
- */
1482
- fanOut: {
1483
- visibilityTimeout: 30,
1484
- receiveMessageWaitTime: 20,
1485
- encrypted: true,
1486
- },
1487
- }
1488
-
1489
- // ============================================================================
1490
- // Realtime (WebSocket) Configuration
1491
- // Laravel Echo / Pusher-compatible broadcasting for Stacks.js
1492
- // Supports both serverless (API Gateway) and server (ts-broadcasting) modes
1493
- // ============================================================================
1494
-
1495
- /**
1496
- * Realtime deployment mode
1497
- * - 'serverless': Uses API Gateway WebSocket + Lambda (auto-scales, pay-per-use)
1498
- * - 'server': Uses ts-broadcasting Bun WebSocket server on EC2/ECS (lowest latency)
1499
- */
1500
- export type RealtimeMode = 'serverless' | 'server'
1501
-
1502
- /**
1503
- * Server mode configuration (ts-broadcasting)
1504
- * High-performance Bun WebSocket server for EC2/ECS deployments
1505
- */
1506
- export interface RealtimeServerConfig {
1507
- /**
1508
- * Server host binding
1509
- * @default '0.0.0.0'
1510
- */
1511
- host?: string
1512
-
1513
- /**
1514
- * Server port
1515
- * @default 6001
1516
- */
1517
- port?: number
1518
-
1519
- /**
1520
- * WebSocket scheme
1521
- * @default 'wss' in production, 'ws' in development
1522
- */
1523
- scheme?: 'ws' | 'wss'
1524
-
1525
- /**
1526
- * Driver to use
1527
- * @default 'bun'
1528
- */
1529
- driver?: 'bun' | 'reverb' | 'pusher' | 'ably'
1530
-
1531
- /**
1532
- * Idle connection timeout in seconds
1533
- * @default 120
1534
- */
1535
- idleTimeout?: number
1536
-
1537
- /**
1538
- * Maximum message payload size in bytes
1539
- * @default 16777216 (16 MB)
1540
- */
1541
- maxPayloadLength?: number
1542
-
1543
- /**
1544
- * Backpressure limit in bytes
1545
- * @default 1048576 (1 MB)
1546
- */
1547
- backpressureLimit?: number
1548
-
1549
- /**
1550
- * Close connection when backpressure limit is reached
1551
- * @default false
1552
- */
1553
- closeOnBackpressureLimit?: boolean
1554
-
1555
- /**
1556
- * Send WebSocket ping frames
1557
- * @default true
1558
- */
1559
- sendPings?: boolean
1560
-
1561
- /**
1562
- * Enable per-message deflate compression
1563
- * @default true
1564
- */
1565
- perMessageDeflate?: boolean
1566
-
1567
- /**
1568
- * Redis configuration for horizontal scaling
1569
- * Enables multiple server instances to share state
1570
- */
1571
- redis?: RealtimeRedisConfig
1572
-
1573
- /**
1574
- * Rate limiting configuration
1575
- */
1576
- rateLimit?: RealtimeRateLimitConfig
1577
-
1578
- /**
1579
- * Message encryption configuration
1580
- */
1581
- encryption?: RealtimeEncryptionConfig
1582
-
1583
- /**
1584
- * Webhook notifications configuration
1585
- */
1586
- webhooks?: RealtimeWebhooksConfig
1587
-
1588
- /**
1589
- * Queue configuration for background jobs
1590
- */
1591
- queue?: RealtimeQueueConfig
1592
-
1593
- /**
1594
- * Load management configuration
1595
- */
1596
- loadManagement?: RealtimeLoadConfig
1597
-
1598
- /**
1599
- * Prometheus metrics endpoint
1600
- * @default false
1601
- */
1602
- metrics?: boolean | {
1603
- enabled: boolean
1604
- path?: string
1605
- }
1606
-
1607
- /**
1608
- * Health check endpoint path
1609
- * @default '/health'
1610
- */
1611
- healthCheckPath?: string
1612
-
1613
- /**
1614
- * Number of server instances to run
1615
- * Used when deploying to EC2/ECS
1616
- * @default 1
1617
- */
1618
- instances?: number
1619
-
1620
- /**
1621
- * Auto-scaling configuration for EC2/ECS
1622
- */
1623
- autoScaling?: {
1624
- min?: number
1625
- max?: number
1626
- targetCPU?: number
1627
- targetConnections?: number
1628
- }
1629
- }
1630
-
1631
- /**
1632
- * Redis configuration for ts-broadcasting horizontal scaling
1633
- */
1634
- export interface RealtimeRedisConfig {
1635
- /**
1636
- * Enable Redis adapter
1637
- * @default false
1638
- */
1639
- enabled?: boolean
1640
-
1641
- /**
1642
- * Redis host
1643
- * @default 'localhost'
1644
- */
1645
- host?: string
1646
-
1647
- /**
1648
- * Redis port
1649
- * @default 6379
1650
- */
1651
- port?: number
1652
-
1653
- /**
1654
- * Redis password
1655
- */
1656
- password?: string
1657
-
1658
- /**
1659
- * Redis database number
1660
- * @default 0
1661
- */
1662
- database?: number
1663
-
1664
- /**
1665
- * Redis connection URL (overrides host/port)
1666
- * @example 'redis://user:pass@localhost:6379/0'
1667
- */
1668
- url?: string
1669
-
1670
- /**
1671
- * Key prefix for Redis keys
1672
- * @default 'broadcasting:'
1673
- */
1674
- keyPrefix?: string
1675
-
1676
- /**
1677
- * Use existing ElastiCache from cache config
1678
- * References infrastructure.cache
1679
- */
1680
- useElastiCache?: boolean
1681
- }
1682
-
1683
- /**
1684
- * Rate limiting for WebSocket connections
1685
- */
1686
- export interface RealtimeRateLimitConfig {
1687
- /**
1688
- * Enable rate limiting
1689
- * @default true
1690
- */
1691
- enabled?: boolean
1692
-
1693
- /**
1694
- * Maximum messages per window
1695
- * @default 100
1696
- */
1697
- max?: number
1698
-
1699
- /**
1700
- * Time window in milliseconds
1701
- * @default 60000 (1 minute)
1702
- */
1703
- window?: number
1704
-
1705
- /**
1706
- * Apply rate limit per channel
1707
- * @default true
1708
- */
1709
- perChannel?: boolean
1710
-
1711
- /**
1712
- * Apply rate limit per user
1713
- * @default true
1714
- */
1715
- perUser?: boolean
1716
- }
1717
-
1718
- /**
1719
- * Message encryption configuration
1720
- */
1721
- export interface RealtimeEncryptionConfig {
1722
- /**
1723
- * Enable message encryption
1724
- * @default false
1725
- */
1726
- enabled?: boolean
1727
-
1728
- /**
1729
- * Encryption algorithm
1730
- * @default 'aes-256-gcm'
1731
- */
1732
- algorithm?: 'aes-256-gcm' | 'aes-128-gcm'
1733
-
1734
- /**
1735
- * Key rotation interval in milliseconds
1736
- * @default 86400000 (24 hours)
1737
- */
1738
- keyRotationInterval?: number
1739
- }
1740
-
1741
- /**
1742
- * Webhook notifications for realtime events
1743
- */
1744
- export interface RealtimeWebhooksConfig {
1745
- /**
1746
- * Enable webhooks
1747
- * @default false
1748
- */
1749
- enabled?: boolean
1750
-
1751
- /**
1752
- * Webhook endpoints for different events
1753
- */
1754
- endpoints?: {
1755
- /**
1756
- * Called when a client connects
1757
- */
1758
- connection?: string
1759
-
1760
- /**
1761
- * Called when a client subscribes to a channel
1762
- */
1763
- subscribe?: string
1764
-
1765
- /**
1766
- * Called when a client unsubscribes
1767
- */
1768
- unsubscribe?: string
1769
-
1770
- /**
1771
- * Called when a client disconnects
1772
- */
1773
- disconnect?: string
1774
-
1775
- /**
1776
- * Custom event webhooks
1777
- */
1778
- [event: string]: string | undefined
1779
- }
1780
- }
1781
-
1782
- /**
1783
- * Queue configuration for background broadcasting
1784
- */
1785
- export interface RealtimeQueueConfig {
1786
- /**
1787
- * Enable queue for broadcast operations
1788
- * @default false
1789
- */
1790
- enabled?: boolean
1791
-
1792
- /**
1793
- * Default queue name
1794
- * @default 'broadcasts'
1795
- */
1796
- defaultQueue?: string
1797
-
1798
- /**
1799
- * Retry configuration
1800
- */
1801
- retry?: {
1802
- attempts?: number
1803
- backoff?: {
1804
- type: 'fixed' | 'exponential'
1805
- delay: number
1806
- }
1807
- }
1808
-
1809
- /**
1810
- * Dead letter queue for failed broadcasts
1811
- */
1812
- deadLetter?: {
1813
- enabled?: boolean
1814
- maxRetries?: number
1815
- }
1816
- }
1817
-
1818
- /**
1819
- * Load management for server mode
1820
- */
1821
- export interface RealtimeLoadConfig {
1822
- /**
1823
- * Enable load management
1824
- * @default true
1825
- */
1826
- enabled?: boolean
1827
-
1828
- /**
1829
- * Maximum concurrent connections
1830
- * @default 10000
1831
- */
1832
- maxConnections?: number
1833
-
1834
- /**
1835
- * Maximum subscriptions per connection
1836
- * @default 100
1837
- */
1838
- maxSubscriptionsPerConnection?: number
1839
-
1840
- /**
1841
- * CPU threshold to start shedding load (0-1)
1842
- * @default 0.8
1843
- */
1844
- shedLoadThreshold?: number
1845
- }
1846
-
1847
- /**
1848
- * Channel authorization configuration
1849
- */
1850
- export interface RealtimeChannelAuth {
1851
- /**
1852
- * Lambda function name for channel authorization
1853
- * Called when clients join private/presence channels
1854
- * @example 'authorizeChannel'
1855
- */
1856
- functionName?: string
1857
-
1858
- /**
1859
- * Authorization endpoint URL (if using external auth)
1860
- * @example 'https://api.example.com/broadcasting/auth'
1861
- */
1862
- endpoint?: string
1863
-
1864
- /**
1865
- * JWT secret for token validation
1866
- * Can reference Secrets Manager: '{{resolve:secretsmanager:my-secret}}'
1867
- */
1868
- jwtSecret?: string
1869
-
1870
- /**
1871
- * Token expiration time in seconds
1872
- * @default 3600
1873
- */
1874
- tokenExpiration?: number
1875
- }
1876
-
1877
- /**
1878
- * Presence channel configuration
1879
- */
1880
- export interface RealtimePresenceConfig {
1881
- /**
1882
- * Enable presence channels (who's online)
1883
- * @default true
1884
- */
1885
- enabled?: boolean
1886
-
1887
- /**
1888
- * Maximum members per presence channel
1889
- * @default 100
1890
- */
1891
- maxMembers?: number
1892
-
1893
- /**
1894
- * How often to send presence heartbeats (seconds)
1895
- * @default 30
1896
- */
1897
- heartbeatInterval?: number
1898
-
1899
- /**
1900
- * Time before considering a member offline (seconds)
1901
- * @default 60
1902
- */
1903
- inactivityTimeout?: number
1904
- }
1905
-
1906
- /**
1907
- * Connection storage configuration
1908
- */
1909
- export interface RealtimeStorageConfig {
1910
- /**
1911
- * Storage type for connection management
1912
- * - 'dynamodb': DynamoDB tables (recommended, auto-scales)
1913
- * - 'elasticache': Redis cluster (lowest latency)
1914
- * @default 'dynamodb'
1915
- */
1916
- type?: 'dynamodb' | 'elasticache'
1917
-
1918
- /**
1919
- * DynamoDB table configuration
1920
- */
1921
- dynamodb?: {
1922
- /**
1923
- * Billing mode for DynamoDB
1924
- * @default 'PAY_PER_REQUEST'
1925
- */
1926
- billingMode?: 'PAY_PER_REQUEST' | 'PROVISIONED'
1927
-
1928
- /**
1929
- * Read capacity units (only for PROVISIONED)
1930
- * @default 5
1931
- */
1932
- readCapacity?: number
1933
-
1934
- /**
1935
- * Write capacity units (only for PROVISIONED)
1936
- * @default 5
1937
- */
1938
- writeCapacity?: number
1939
-
1940
- /**
1941
- * Enable point-in-time recovery
1942
- * @default false
1943
- */
1944
- pointInTimeRecovery?: boolean
1945
-
1946
- /**
1947
- * TTL for connection records (seconds)
1948
- * @default 86400 (24 hours)
1949
- */
1950
- connectionTTL?: number
1951
- }
1952
-
1953
- /**
1954
- * ElastiCache configuration (if using Redis)
1955
- */
1956
- elasticache?: {
1957
- /**
1958
- * Node type for Redis cluster
1959
- * @default 'cache.t3.micro'
1960
- */
1961
- nodeType?: string
1962
-
1963
- /**
1964
- * Number of cache nodes
1965
- * @default 1
1966
- */
1967
- numNodes?: number
1968
- }
1969
- }
1970
-
1971
- /**
1972
- * WebSocket scaling configuration
1973
- */
1974
- export interface RealtimeScalingConfig {
1975
- /**
1976
- * Maximum concurrent connections
1977
- * @default 10000
1978
- */
1979
- maxConnections?: number
1980
-
1981
- /**
1982
- * Message throughput limit per second
1983
- * @default 1000
1984
- */
1985
- messagesPerSecond?: number
1986
-
1987
- /**
1988
- * Lambda memory for WebSocket handlers (MB)
1989
- * @default 256
1990
- */
1991
- handlerMemory?: number
1992
-
1993
- /**
1994
- * Lambda timeout for WebSocket handlers (seconds)
1995
- * @default 30
1996
- */
1997
- handlerTimeout?: number
1998
-
1999
- /**
2000
- * Enable Lambda provisioned concurrency for low latency
2001
- */
2002
- provisionedConcurrency?: number
2003
- }
2004
-
2005
- /**
2006
- * Realtime monitoring and alarms
2007
- */
2008
- export interface RealtimeMonitoringConfig {
2009
- /**
2010
- * Enable CloudWatch alarms
2011
- * @default false
2012
- */
2013
- enabled?: boolean
2014
-
2015
- /**
2016
- * Alert when concurrent connections exceed threshold
2017
- * @default 8000
2018
- */
2019
- connectionThreshold?: number
2020
-
2021
- /**
2022
- * Alert when message errors exceed threshold per minute
2023
- * @default 100
2024
- */
2025
- errorThreshold?: number
2026
-
2027
- /**
2028
- * Alert when latency exceeds threshold (ms)
2029
- * @default 1000
2030
- */
2031
- latencyThreshold?: number
2032
-
2033
- /**
2034
- * SNS topic ARN for alarm notifications
2035
- */
2036
- notificationTopicArn?: string
2037
-
2038
- /**
2039
- * Email addresses for alarm notifications
2040
- */
2041
- notificationEmails?: string[]
2042
- }
2043
-
2044
- /**
2045
- * Realtime event hooks
2046
- */
2047
- export interface RealtimeHooksConfig {
2048
- /**
2049
- * Lambda function called on new connections
2050
- * Receives: { connectionId, requestContext }
2051
- */
2052
- onConnect?: string
2053
-
2054
- /**
2055
- * Lambda function called on disconnections
2056
- * Receives: { connectionId, requestContext }
2057
- */
2058
- onDisconnect?: string
2059
-
2060
- /**
2061
- * Lambda function called for incoming messages
2062
- * Receives: { connectionId, body, requestContext }
2063
- */
2064
- onMessage?: string
2065
-
2066
- /**
2067
- * Lambda function called when clients subscribe to channels
2068
- * Receives: { connectionId, channel, auth }
2069
- */
2070
- onSubscribe?: string
2071
-
2072
- /**
2073
- * Lambda function called when clients unsubscribe
2074
- * Receives: { connectionId, channel }
2075
- */
2076
- onUnsubscribe?: string
2077
- }
2078
-
2079
- /**
2080
- * Realtime (WebSocket) Configuration
2081
- * Provides Laravel Echo / Pusher-compatible broadcasting
2082
- *
2083
- * @example Serverless mode (API Gateway WebSocket)
2084
- * realtime: {
2085
- * enabled: true,
2086
- * mode: 'serverless',
2087
- * channels: { public: true, private: true, presence: true },
2088
- * }
2089
- *
2090
- * @example Server mode (ts-broadcasting on EC2/ECS)
2091
- * realtime: {
2092
- * enabled: true,
2093
- * mode: 'server',
2094
- * server: {
2095
- * port: 6001,
2096
- * redis: { enabled: true, host: 'redis.example.com' },
2097
- * rateLimit: { max: 100, window: 60000 },
2098
- * },
2099
- * }
2100
- *
2101
- * @example Production server mode with clustering
2102
- * realtime: {
2103
- * enabled: true,
2104
- * mode: 'server',
2105
- * server: {
2106
- * port: 6001,
2107
- * instances: 3,
2108
- * redis: { enabled: true, useElastiCache: true },
2109
- * autoScaling: { min: 2, max: 10, targetCPU: 70 },
2110
- * metrics: true,
2111
- * },
2112
- * channels: { public: true, private: true, presence: true },
2113
- * }
2114
- *
2115
- * @example Integration with Stacks.js
2116
- * // In your Stacks app:
2117
- * import { Broadcast } from '@stacksjs/broadcast'
2118
- *
2119
- * // Broadcast to a channel
2120
- * Broadcast.channel('orders').emit('order.created', { id: 123 })
2121
- *
2122
- * // Client-side (similar to Laravel Echo)
2123
- * Echo.channel('orders').listen('order.created', (e) => {
2124
- * console.log('New order:', e.id)
2125
- * })
2126
- *
2127
- * // Private channel
2128
- * Echo.private(`user.${userId}`).listen('notification', (e) => {
2129
- * console.log('Private notification:', e)
2130
- * })
2131
- *
2132
- * // Presence channel
2133
- * Echo.join('chat-room')
2134
- * .here((users) => console.log('Online:', users))
2135
- * .joining((user) => console.log('Joined:', user))
2136
- * .leaving((user) => console.log('Left:', user))
2137
- */
2138
- export interface RealtimeConfig {
2139
- /**
2140
- * Enable realtime/WebSocket support
2141
- * @default false
2142
- */
2143
- enabled?: boolean
2144
-
2145
- /**
2146
- * Deployment mode
2147
- * - 'serverless': API Gateway WebSocket + Lambda (auto-scales, pay-per-use)
2148
- * - 'server': ts-broadcasting Bun WebSocket on EC2/ECS (lowest latency)
2149
- * @default 'serverless'
2150
- */
2151
- mode?: RealtimeMode
2152
-
2153
- /**
2154
- * Custom WebSocket API/server name
2155
- */
2156
- name?: string
2157
-
2158
- /**
2159
- * Server mode configuration (ts-broadcasting)
2160
- * Only used when mode is 'server'
2161
- */
2162
- server?: RealtimeServerConfig
2163
-
2164
- /**
2165
- * Channel configuration
2166
- */
2167
- channels?: {
2168
- /**
2169
- * Enable public channels (no auth required)
2170
- * @default true
2171
- */
2172
- public?: boolean
2173
-
2174
- /**
2175
- * Enable private channels (requires auth)
2176
- * @default true
2177
- */
2178
- private?: boolean
2179
-
2180
- /**
2181
- * Enable presence channels (track online users)
2182
- * @default false
2183
- */
2184
- presence?: boolean | RealtimePresenceConfig
2185
- }
2186
-
2187
- /**
2188
- * Channel authorization configuration
2189
- */
2190
- auth?: RealtimeChannelAuth
2191
-
2192
- /**
2193
- * Connection storage configuration
2194
- */
2195
- storage?: RealtimeStorageConfig
2196
-
2197
- /**
2198
- * Scaling configuration
2199
- */
2200
- scaling?: RealtimeScalingConfig
2201
-
2202
- /**
2203
- * Monitoring and alarms
2204
- */
2205
- monitoring?: RealtimeMonitoringConfig
2206
-
2207
- /**
2208
- * Event hooks (Lambda functions)
2209
- */
2210
- hooks?: RealtimeHooksConfig
2211
-
2212
- /**
2213
- * Custom domain for WebSocket endpoint
2214
- * @example 'ws.example.com'
2215
- */
2216
- customDomain?: string
2217
-
2218
- /**
2219
- * ACM certificate ARN for custom domain
2220
- */
2221
- certificateArn?: string
2222
-
2223
- /**
2224
- * Enable connection keep-alive pings
2225
- * @default true
2226
- */
2227
- keepAlive?: boolean
2228
-
2229
- /**
2230
- * Keep-alive interval in seconds
2231
- * @default 30
2232
- */
2233
- keepAliveInterval?: number
2234
-
2235
- /**
2236
- * Idle connection timeout in seconds
2237
- * @default 600 (10 minutes)
2238
- */
2239
- idleTimeout?: number
2240
-
2241
- /**
2242
- * Maximum message size in bytes
2243
- * @default 32768 (32 KB)
2244
- */
2245
- maxMessageSize?: number
2246
-
2247
- /**
2248
- * Enable message compression
2249
- * @default false
2250
- */
2251
- compression?: boolean
2252
-
2253
- /**
2254
- * Custom tags for all realtime resources
2255
- */
2256
- tags?: Record<string, string>
2257
- }
2258
-
2259
- /**
2260
- * Realtime configuration presets
2261
- *
2262
- * @example Serverless presets
2263
- * import { RealtimePresets } from '@stacksjs/ts-cloud-types'
2264
- * realtime: RealtimePresets.serverless.production
2265
- *
2266
- * @example Server presets (ts-broadcasting)
2267
- * realtime: RealtimePresets.server.production
2268
- */
2269
- export const RealtimePresets: {
2270
- serverless: {
2271
- development: RealtimeConfig
2272
- production: RealtimeConfig
2273
- notifications: RealtimeConfig
2274
- }
2275
- server: {
2276
- development: RealtimeConfig
2277
- production: RealtimeConfig
2278
- highPerformance: RealtimeConfig
2279
- chat: RealtimeConfig
2280
- gaming: RealtimeConfig
2281
- single: RealtimeConfig
2282
- }
2283
- } = {
2284
- // ============================================
2285
- // SERVERLESS MODE PRESETS (API Gateway WebSocket)
2286
- // ============================================
2287
- serverless: {
2288
- /**
2289
- * Development preset - minimal resources
2290
- */
2291
- development: {
2292
- enabled: true,
2293
- mode: 'serverless',
2294
- channels: {
2295
- public: true,
2296
- private: true,
2297
- presence: true,
2298
- },
2299
- storage: {
2300
- type: 'dynamodb',
2301
- dynamodb: { billingMode: 'PAY_PER_REQUEST' },
2302
- },
2303
- scaling: {
2304
- maxConnections: 1000,
2305
- handlerMemory: 128,
2306
- },
2307
- },
2308
-
2309
- /**
2310
- * Production preset - scalable with monitoring
2311
- */
2312
- production: {
2313
- enabled: true,
2314
- mode: 'serverless',
2315
- channels: {
2316
- public: true,
2317
- private: true,
2318
- presence: {
2319
- enabled: true,
2320
- maxMembers: 100,
2321
- heartbeatInterval: 30,
2322
- inactivityTimeout: 60,
2323
- },
2324
- },
2325
- storage: {
2326
- type: 'dynamodb',
2327
- dynamodb: {
2328
- billingMode: 'PAY_PER_REQUEST',
2329
- pointInTimeRecovery: true,
2330
- connectionTTL: 86400,
2331
- },
2332
- },
2333
- scaling: {
2334
- maxConnections: 50000,
2335
- messagesPerSecond: 5000,
2336
- handlerMemory: 256,
2337
- handlerTimeout: 30,
2338
- },
2339
- monitoring: {
2340
- enabled: true,
2341
- connectionThreshold: 40000,
2342
- errorThreshold: 100,
2343
- latencyThreshold: 500,
2344
- },
2345
- keepAlive: true,
2346
- keepAliveInterval: 30,
2347
- idleTimeout: 600,
2348
- },
2349
-
2350
- /**
2351
- * Notifications only preset - no presence
2352
- */
2353
- notifications: {
2354
- enabled: true,
2355
- mode: 'serverless',
2356
- channels: {
2357
- public: false,
2358
- private: true,
2359
- presence: false,
2360
- },
2361
- storage: {
2362
- type: 'dynamodb',
2363
- dynamodb: { billingMode: 'PAY_PER_REQUEST' },
2364
- },
2365
- scaling: {
2366
- maxConnections: 50000,
2367
- messagesPerSecond: 2000,
2368
- handlerMemory: 128,
2369
- },
2370
- keepAlive: true,
2371
- keepAliveInterval: 60,
2372
- idleTimeout: 1800,
2373
- },
2374
- },
2375
-
2376
- // ============================================
2377
- // SERVER MODE PRESETS (ts-broadcasting / Bun)
2378
- // ============================================
2379
- server: {
2380
- /**
2381
- * Development preset - single server, no clustering
2382
- */
2383
- development: {
2384
- enabled: true,
2385
- mode: 'server',
2386
- channels: {
2387
- public: true,
2388
- private: true,
2389
- presence: true,
2390
- },
2391
- server: {
2392
- host: '0.0.0.0',
2393
- port: 6001,
2394
- scheme: 'ws',
2395
- driver: 'bun',
2396
- idleTimeout: 120,
2397
- perMessageDeflate: false, // Faster in dev
2398
- metrics: false,
2399
- },
2400
- },
2401
-
2402
- /**
2403
- * Production preset - clustered with Redis
2404
- */
2405
- production: {
2406
- enabled: true,
2407
- mode: 'server',
2408
- channels: {
2409
- public: true,
2410
- private: true,
2411
- presence: true,
2412
- },
2413
- server: {
2414
- host: '0.0.0.0',
2415
- port: 6001,
2416
- scheme: 'wss',
2417
- driver: 'bun',
2418
- idleTimeout: 120,
2419
- maxPayloadLength: 16 * 1024 * 1024, // 16 MB
2420
- backpressureLimit: 1024 * 1024, // 1 MB
2421
- sendPings: true,
2422
- perMessageDeflate: true,
2423
- instances: 2,
2424
- redis: {
2425
- enabled: true,
2426
- keyPrefix: 'broadcasting:',
2427
- },
2428
- rateLimit: {
2429
- enabled: true,
2430
- max: 100,
2431
- window: 60000,
2432
- perChannel: true,
2433
- perUser: true,
2434
- },
2435
- loadManagement: {
2436
- enabled: true,
2437
- maxConnections: 10000,
2438
- maxSubscriptionsPerConnection: 100,
2439
- shedLoadThreshold: 0.8,
2440
- },
2441
- metrics: true,
2442
- autoScaling: {
2443
- min: 2,
2444
- max: 10,
2445
- targetCPU: 70,
2446
- },
2447
- },
2448
- monitoring: {
2449
- enabled: true,
2450
- connectionThreshold: 8000,
2451
- errorThreshold: 100,
2452
- },
2453
- },
2454
-
2455
- /**
2456
- * High-performance preset - optimized for lowest latency
2457
- */
2458
- highPerformance: {
2459
- enabled: true,
2460
- mode: 'server',
2461
- channels: {
2462
- public: true,
2463
- private: true,
2464
- presence: true,
2465
- },
2466
- server: {
2467
- host: '0.0.0.0',
2468
- port: 6001,
2469
- scheme: 'wss',
2470
- driver: 'bun',
2471
- idleTimeout: 60,
2472
- maxPayloadLength: 8 * 1024 * 1024, // 8 MB
2473
- backpressureLimit: 2 * 1024 * 1024, // 2 MB
2474
- closeOnBackpressureLimit: true,
2475
- sendPings: true,
2476
- perMessageDeflate: true,
2477
- instances: 4,
2478
- redis: {
2479
- enabled: true,
2480
- useElastiCache: true,
2481
- keyPrefix: 'rt:',
2482
- },
2483
- rateLimit: {
2484
- enabled: true,
2485
- max: 200,
2486
- window: 60000,
2487
- perChannel: true,
2488
- },
2489
- loadManagement: {
2490
- enabled: true,
2491
- maxConnections: 25000,
2492
- maxSubscriptionsPerConnection: 50,
2493
- shedLoadThreshold: 0.7,
2494
- },
2495
- metrics: { enabled: true, path: '/metrics' },
2496
- autoScaling: {
2497
- min: 4,
2498
- max: 20,
2499
- targetCPU: 60,
2500
- targetConnections: 20000,
2501
- },
2502
- },
2503
- monitoring: {
2504
- enabled: true,
2505
- connectionThreshold: 80000,
2506
- errorThreshold: 50,
2507
- latencyThreshold: 50,
2508
- },
2509
- },
2510
-
2511
- /**
2512
- * Chat application preset - optimized for presence and typing indicators
2513
- */
2514
- chat: {
2515
- enabled: true,
2516
- mode: 'server',
2517
- channels: {
2518
- public: true,
2519
- private: true,
2520
- presence: {
2521
- enabled: true,
2522
- maxMembers: 200,
2523
- heartbeatInterval: 20,
2524
- inactivityTimeout: 60,
2525
- },
2526
- },
2527
- server: {
2528
- host: '0.0.0.0',
2529
- port: 6001,
2530
- scheme: 'wss',
2531
- driver: 'bun',
2532
- idleTimeout: 300, // 5 minutes for chat
2533
- maxPayloadLength: 1024 * 1024, // 1 MB (smaller for chat)
2534
- sendPings: true,
2535
- perMessageDeflate: true,
2536
- instances: 2,
2537
- redis: {
2538
- enabled: true,
2539
- keyPrefix: 'chat:',
2540
- },
2541
- rateLimit: {
2542
- enabled: true,
2543
- max: 60, // 1 message per second
2544
- window: 60000,
2545
- perChannel: true,
2546
- },
2547
- loadManagement: {
2548
- enabled: true,
2549
- maxConnections: 15000,
2550
- maxSubscriptionsPerConnection: 20,
2551
- },
2552
- metrics: true,
2553
- },
2554
- keepAlive: true,
2555
- keepAliveInterval: 25,
2556
- idleTimeout: 900,
2557
- },
2558
-
2559
- /**
2560
- * Gaming/real-time app preset - ultra-low latency
2561
- */
2562
- gaming: {
2563
- enabled: true,
2564
- mode: 'server',
2565
- channels: {
2566
- public: true,
2567
- private: true,
2568
- presence: {
2569
- enabled: true,
2570
- maxMembers: 100,
2571
- heartbeatInterval: 10,
2572
- inactivityTimeout: 30,
2573
- },
2574
- },
2575
- server: {
2576
- host: '0.0.0.0',
2577
- port: 6001,
2578
- scheme: 'wss',
2579
- driver: 'bun',
2580
- idleTimeout: 30,
2581
- maxPayloadLength: 64 * 1024, // 64 KB (small, fast messages)
2582
- backpressureLimit: 512 * 1024, // 512 KB
2583
- closeOnBackpressureLimit: true,
2584
- sendPings: true,
2585
- perMessageDeflate: false, // Disable for lowest latency
2586
- instances: 4,
2587
- redis: {
2588
- enabled: true,
2589
- useElastiCache: true,
2590
- },
2591
- rateLimit: {
2592
- enabled: true,
2593
- max: 120, // 2 messages per second
2594
- window: 60000,
2595
- },
2596
- loadManagement: {
2597
- enabled: true,
2598
- maxConnections: 5000,
2599
- maxSubscriptionsPerConnection: 10,
2600
- shedLoadThreshold: 0.6,
2601
- },
2602
- metrics: true,
2603
- autoScaling: {
2604
- min: 4,
2605
- max: 16,
2606
- targetCPU: 50,
2607
- },
2608
- },
2609
- keepAlive: true,
2610
- keepAliveInterval: 10,
2611
- idleTimeout: 60,
2612
- },
2613
-
2614
- /**
2615
- * Single server preset - no clustering, simple setup
2616
- */
2617
- single: {
2618
- enabled: true,
2619
- mode: 'server',
2620
- channels: {
2621
- public: true,
2622
- private: true,
2623
- presence: true,
2624
- },
2625
- server: {
2626
- host: '0.0.0.0',
2627
- port: 6001,
2628
- scheme: 'wss',
2629
- driver: 'bun',
2630
- idleTimeout: 120,
2631
- sendPings: true,
2632
- perMessageDeflate: true,
2633
- instances: 1,
2634
- rateLimit: {
2635
- enabled: true,
2636
- max: 100,
2637
- window: 60000,
2638
- },
2639
- loadManagement: {
2640
- enabled: true,
2641
- maxConnections: 10000,
2642
- },
2643
- metrics: true,
2644
- },
2645
- },
2646
- },
2647
- }
2648
-
2649
- export interface ApiConfig {
2650
- enabled?: boolean
2651
- name?: string
2652
- }
2653
-
2654
- /**
2655
- * Load Balancer Configuration
2656
- * Controls whether and how traffic is load balanced
2657
- */
2658
- export interface LoadBalancerConfig {
2659
- /**
2660
- * Enable Application Load Balancer
2661
- * When false, traffic goes directly to EC2 instances
2662
- * @default true for production with SSL
2663
- */
2664
- enabled?: boolean
2665
-
2666
- /**
2667
- * Load balancer type
2668
- * - 'application': HTTP/HTTPS traffic (ALB)
2669
- * - 'network': TCP/UDP traffic (NLB)
2670
- * @default 'application'
2671
- */
2672
- type?: 'application' | 'network'
2673
-
2674
- /**
2675
- * Health check configuration
2676
- */
2677
- healthCheck?: {
2678
- path?: string
2679
- interval?: number
2680
- timeout?: number
2681
- healthyThreshold?: number
2682
- unhealthyThreshold?: number
2683
- }
2684
-
2685
- /**
2686
- * Idle timeout in seconds
2687
- * @default 60
2688
- */
2689
- idleTimeout?: number
2690
-
2691
- /**
2692
- * Enable access logs
2693
- */
2694
- accessLogs?: {
2695
- enabled?: boolean
2696
- bucket?: string
2697
- prefix?: string
2698
- }
2699
- }
2700
-
2701
- /**
2702
- * SSL/TLS Configuration
2703
- * Supports both AWS ACM certificates and Let's Encrypt
2704
- */
2705
- export interface SslConfig {
2706
- /**
2707
- * Enable HTTPS
2708
- * @default true for production
2709
- */
2710
- enabled?: boolean
2711
-
2712
- /**
2713
- * SSL certificate provider
2714
- * - 'acm': AWS Certificate Manager (requires ALB or CloudFront)
2715
- * - 'letsencrypt': Free certificates from Let's Encrypt (works without ALB)
2716
- * @default 'acm' if loadBalancer.enabled, otherwise 'letsencrypt'
2717
- */
2718
- provider?: 'acm' | 'letsencrypt'
2719
-
2720
- /**
2721
- * ACM certificate ARN (if using ACM)
2722
- * If not provided, a certificate will be automatically requested
2723
- */
2724
- certificateArn?: string
2725
-
2726
- /**
2727
- * Domain names for the certificate
2728
- * If not provided, uses the primary domain from dns config
2729
- */
2730
- domains?: string[]
2731
-
2732
- /**
2733
- * Redirect HTTP to HTTPS
2734
- * @default true when SSL is enabled
2735
- */
2736
- redirectHttp?: boolean
2737
-
2738
- /**
2739
- * Let's Encrypt specific options
2740
- */
2741
- letsEncrypt?: {
2742
- /**
2743
- * Email for Let's Encrypt notifications
2744
- */
2745
- email?: string
2746
-
2747
- /**
2748
- * Use staging server for testing
2749
- * @default false
2750
- */
2751
- staging?: boolean
2752
-
2753
- /**
2754
- * Auto-renew certificates
2755
- * @default true
2756
- */
2757
- autoRenew?: boolean
2758
- }
2759
- }