//native
type Neondb = {
apiKey: string
}
/**
* Create a project
* Creates a Neon project.
A project is the top-level object in the Neon object hierarchy.
Plan limits define how many projects you can create.
For more information, see [Manage projects](https://neon.tech/docs/manage/projects/).
You can specify a region and Postgres version in the request body.
Neon currently supports PostgreSQL 14, 15, 16, and 17.
For supported regions and `region_id` values, see [Regions](https://neon.tech/docs/introduction/regions/).
*/
export async function main(
auth: Neondb,
body: {
project: {
settings?: {
quota?: {
active_time_seconds?: number
compute_time_seconds?: number
written_data_bytes?: number
data_transfer_bytes?: number
logical_size_bytes?: number
}
allowed_ips?: {
ips?: string[]
protected_branches_only?: false | true
}
enable_logical_replication?: false | true
maintenance_window?: {
weekdays: number[]
start_time: string
end_time: string
}
block_public_connections?: false | true
block_vpc_connections?: false | true
}
name?: string
branch?: { name?: string; role_name?: string; database_name?: string }
autoscaling_limit_min_cu?: number
autoscaling_limit_max_cu?: number
provisioner?: string
region_id?: string
default_endpoint_settings?: {
pg_settings?: {}
pgbouncer_settings?: {}
autoscaling_limit_min_cu?: number
autoscaling_limit_max_cu?: number
suspend_timeout_seconds?: number
}
pg_version?: number
store_passwords?: false | true
history_retention_seconds?: number
org_id?: string
}
}
) {
const url = new URL(`https://console.neon.tech/api/v2/projects`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago