Skip to content

Commit 607f080

Browse files
committed
chore: wip
1 parent 9afd99c commit 607f080

File tree

20 files changed

+1833
-308
lines changed

20 files changed

+1833
-308
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ stacks.log
4141
.stx
4242
.stx-serve
4343
.env.keys
44+
/storage/framework/frontend-dist

app/Actions/HealthAction.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Simple health check action that doesn't require @stacksjs/actions
2+
// This overrides the default framework health check
3+
4+
import { route } from '@stacksjs/router'
5+
6+
export default {
7+
name: 'Health',
8+
description: 'Health check for ECS',
9+
path: '/health',
10+
11+
async handle() {
12+
return {
13+
status: 'ok',
14+
timestamp: Date.now(),
15+
}
16+
},
17+
}
18+
19+
// Also register as a route for redundancy
20+
route.get('/health', () => {
21+
return { status: 'ok', timestamp: Date.now() }
22+
})

config/cloud.ts

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,31 @@ export const tsCloud: TsCloudConfig = {
6565
* Define your cloud resources here
6666
*/
6767
infrastructure: {
68+
/**
69+
* Deployment Mode
70+
*
71+
* - 'server': Traditional EC2-based deployment (Forge-style)
72+
* - EC2 instances running your full-stack Bun app
73+
* - Application Load Balancer for traffic distribution
74+
* - Suitable for monolithic applications
75+
*
76+
* - 'serverless': Container + static site deployment (Vapor-style)
77+
* - ECS Fargate for API (Bun running in containers)
78+
* - S3 + CloudFront for frontend (static assets)
79+
* - Better cost optimization and auto-scaling
80+
*/
81+
mode: 'serverless', // 'server' | 'serverless'
82+
6883
/**
6984
* Compute Configuration
7085
*
71-
* Defines the instances running your Stacks/Bun application.
86+
* For mode: 'server'
87+
* Defines the EC2 instances running your Stacks/Bun application.
7288
* When instances > 1, load balancer is automatically enabled.
7389
*
90+
* For mode: 'serverless'
91+
* These settings are not used. See 'containers' configuration instead.
92+
*
7493
* @example Single instance (development/staging)
7594
* compute: { instances: 1, size: 'micro' }
7695
*
@@ -124,6 +143,53 @@ export const tsCloud: TsCloudConfig = {
124143
// },
125144
},
126145

146+
/**
147+
* Container Configuration (for serverless mode only)
148+
*
149+
* Defines ECS Fargate containers running your Bun API.
150+
* Only used when mode: 'serverless'.
151+
*
152+
* @example Basic API container
153+
* containers: {
154+
* api: {
155+
* cpu: 256, // 0.25 vCPU
156+
* memory: 512, // 512 MB
157+
* port: 3000,
158+
* healthCheck: '/health',
159+
* }
160+
* }
161+
*
162+
* @example Production API with auto-scaling
163+
* containers: {
164+
* api: {
165+
* cpu: 512,
166+
* memory: 1024,
167+
* port: 3000,
168+
* desiredCount: 2,
169+
* autoScaling: {
170+
* min: 2,
171+
* max: 10,
172+
* targetCpuUtilization: 70,
173+
* },
174+
* }
175+
* }
176+
*/
177+
containers: {
178+
api: {
179+
cpu: 512, // 256, 512, 1024, 2048, 4096
180+
memory: 1024, // Must be compatible with CPU (512 MB - 16 GB)
181+
port: 3000,
182+
healthCheck: '/health',
183+
desiredCount: 2,
184+
autoScaling: {
185+
min: 1,
186+
max: 10,
187+
targetCpuUtilization: 70,
188+
targetMemoryUtilization: 80,
189+
},
190+
},
191+
},
192+
127193
/**
128194
* Load Balancer Configuration
129195
*

routes/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ route.post('/verify-authentication', 'Actions/Auth/VerifyAuthenticationAction')
2424
route.get('/coming-soon', 'Controllers/ComingSoonController@index')
2525

2626
// route.email('/welcome')
27-
route.health() // adds a GET `/health` route
27+
await route.health() // adds a GET `/health` route
2828
route.get('/install', 'Actions/InstallAction')
2929
route.post('/ai/ask', 'Actions/AI/AskAction')
3030
route.post('/ai/summary', 'Actions/AI/SummaryAction')

0 commit comments

Comments
 (0)