-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathneon.ts
More file actions
62 lines (55 loc) · 1.46 KB
/
Copy pathneon.ts
File metadata and controls
62 lines (55 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* Neon Infrastructure as Code (neon.ts)
* Declares services and branch-level policies for the RUN APPAREL monorepo.
*/
export interface NeonBranchTarget {
name: string;
exists?: boolean;
isDefault?: boolean;
parentId?: string;
}
export interface NeonBranchConfig {
parent?: string;
ttl?: string;
protected?: boolean;
postgres?: {
computeSettings?: {
autoscalingLimitMinCu?: number;
autoscalingLimitMaxCu?: number;
suspendTimeout?: string;
};
};
}
export interface NeonProjectConfig {
auth?: boolean;
dataApi?: boolean;
branch?: (branch: NeonBranchTarget) => NeonBranchConfig;
}
export function defineConfig(config: NeonProjectConfig): NeonProjectConfig {
return config;
}
export default defineConfig({
auth: true,
dataApi: true,
branch: (branch: NeonBranchTarget): NeonBranchConfig => {
// 1. Primary canonical branch ('main' / default) is always protected
if (branch.isDefault || branch.name === "main") {
return { protected: true };
}
// 2. Ephemeral preview/dev branches auto-expire in 24h with scale-to-zero compute
if (!branch.exists && (branch.name.startsWith("preview/") || branch.name.startsWith("dev-"))) {
return {
parent: "main",
ttl: "24h",
postgres: {
computeSettings: {
autoscalingLimitMinCu: 0.25,
autoscalingLimitMaxCu: 1,
suspendTimeout: "5m",
},
},
};
}
return {};
},
});