Skip to content

Commit 585e0ca

Browse files
committed
chore: wip
1 parent 17ef490 commit 585e0ca

12 files changed

Lines changed: 2598 additions & 73 deletions

File tree

bunfig.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[install]
22
registry = { url = "https://registry.npmjs.org/", token = "$BUN_AUTH_TOKEN" }
33
linker = "hoisted"
4+
5+
[run]
6+
# Enable TypeScript configuration paths
7+
bun = true

cloud.config.ts

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
import type { CloudConfig } from '@ts-cloud/types'
2+
3+
/**
4+
* TS Cloud Configuration
5+
*
6+
* This file defines your cloud infrastructure configuration.
7+
* Supports both server mode (Forge-style) and serverless mode (Vapor-style).
8+
*
9+
* Environment variables:
10+
* - CLOUD_ENV: Set the active environment (production, staging, development)
11+
* - NODE_ENV: Fallback for CLOUD_ENV
12+
*
13+
* @see https://github.com/stacksjs/ts-cloud
14+
*/
15+
const config: CloudConfig = {
16+
/**
17+
* Project configuration
18+
*/
19+
project: {
20+
name: 'TS Cloud',
21+
slug: 'ts-cloud',
22+
region: 'us-east-1', // Default AWS region
23+
},
24+
25+
/**
26+
* Deployment mode
27+
* - 'server': Traditional EC2-based deployment (Forge-style)
28+
* - 'serverless': Container/Lambda-based deployment (Vapor-style)
29+
* - 'hybrid': Mix of both server and serverless
30+
*/
31+
mode: 'serverless',
32+
33+
/**
34+
* Environment configurations
35+
* Each environment can have its own settings
36+
*/
37+
environments: {
38+
production: {
39+
type: 'production',
40+
region: 'us-east-1',
41+
variables: {
42+
NODE_ENV: 'production',
43+
LOG_LEVEL: 'info',
44+
},
45+
},
46+
staging: {
47+
type: 'staging',
48+
region: 'us-east-1',
49+
variables: {
50+
NODE_ENV: 'staging',
51+
LOG_LEVEL: 'debug',
52+
},
53+
},
54+
development: {
55+
type: 'development',
56+
region: 'us-east-1',
57+
variables: {
58+
NODE_ENV: 'development',
59+
LOG_LEVEL: 'debug',
60+
},
61+
},
62+
},
63+
64+
/**
65+
* Infrastructure configuration
66+
* Define your cloud resources here
67+
*/
68+
infrastructure: {
69+
/**
70+
* VPC Configuration (optional)
71+
* Creates a Virtual Private Cloud for your resources
72+
*/
73+
vpc: {
74+
cidr: '10.0.0.0/16',
75+
zones: 2, // Number of availability zones
76+
natGateway: true, // Enable NAT gateway for private subnets
77+
},
78+
79+
/**
80+
* Storage Configuration
81+
* S3 buckets for files, backups, etc.
82+
*/
83+
storage: {
84+
buckets: [
85+
{
86+
name: 'assets',
87+
public: true,
88+
website: true,
89+
encryption: true,
90+
versioning: false,
91+
},
92+
{
93+
name: 'uploads',
94+
public: false,
95+
encryption: true,
96+
versioning: true,
97+
},
98+
{
99+
name: 'backups',
100+
public: false,
101+
encryption: true,
102+
versioning: true,
103+
},
104+
],
105+
},
106+
107+
/**
108+
* Compute Configuration
109+
* Server or serverless compute resources
110+
*/
111+
compute: {
112+
mode: 'serverless',
113+
114+
// Server mode (EC2) configuration
115+
server: {
116+
instanceType: 't3.small',
117+
ami: 'ami-0c55b159cbfafe1f0', // Amazon Linux 2023
118+
autoScaling: {
119+
min: 1,
120+
max: 5,
121+
desired: 2,
122+
},
123+
},
124+
125+
// Serverless mode (ECS/Lambda) configuration
126+
serverless: {
127+
cpu: 512, // CPU units
128+
memory: 1024, // Memory in MB
129+
desiredCount: 2, // Number of tasks
130+
},
131+
},
132+
133+
/**
134+
* Database Configuration
135+
*/
136+
database: {
137+
type: 'rds', // 'rds' for relational, 'dynamodb' for NoSQL
138+
engine: 'postgres',
139+
instanceType: 'db.t3.micro',
140+
},
141+
142+
/**
143+
* Cache Configuration
144+
*/
145+
cache: {
146+
type: 'redis',
147+
nodeType: 'cache.t3.micro',
148+
},
149+
150+
/**
151+
* CDN Configuration
152+
* CloudFront distribution for global content delivery
153+
*/
154+
cdn: {
155+
enabled: true,
156+
customDomain: 'cdn.example.com',
157+
// certificateArn will be auto-created if not provided
158+
},
159+
160+
/**
161+
* DNS Configuration
162+
* Route53 hosted zone and records
163+
*/
164+
dns: {
165+
domain: 'example.com',
166+
// hostedZoneId: 'Z1234567890ABC', // Optional: use existing hosted zone
167+
},
168+
169+
/**
170+
* Security Configuration
171+
*/
172+
security: {
173+
// Web Application Firewall
174+
waf: {
175+
enabled: true,
176+
blockCountries: ['CN', 'RU', 'KP'], // Geo-blocking
177+
blockIps: ['192.0.2.0/24'], // IP blocking
178+
rateLimit: 2000, // Requests per 5 minutes
179+
},
180+
// KMS encryption
181+
kms: true,
182+
},
183+
184+
/**
185+
* Monitoring Configuration
186+
*/
187+
monitoring: {
188+
dashboards: true,
189+
alarms: [
190+
{
191+
name: 'HighCPU',
192+
metric: 'CPUUtilization',
193+
threshold: 80,
194+
},
195+
{
196+
name: 'HighMemory',
197+
metric: 'MemoryUtilization',
198+
threshold: 80,
199+
},
200+
],
201+
},
202+
},
203+
204+
/**
205+
* Sites Configuration (optional)
206+
* For multi-site deployments
207+
*/
208+
sites: {
209+
main: {
210+
root: '/var/www/main',
211+
path: '/',
212+
domain: 'example.com',
213+
},
214+
api: {
215+
root: '/var/www/api',
216+
path: '/api',
217+
domain: 'api.example.com',
218+
},
219+
},
220+
}
221+
222+
export default config

0 commit comments

Comments
 (0)