neondb
Version:
create a claimable Neon database in seconds!
27 lines (24 loc) • 692 B
JavaScript
import open from 'open';
import pWaitFor from 'p-wait-for';
import { LAUNCHPAD_URLS } from './urls.js';
async function createClaimableDatabase(dbId, launchpadUrl) {
void open(launchpadUrl.href);
const connString = await pWaitFor(
async () => {
const apiUrl = LAUNCHPAD_URLS.GET_DATABASE_DATA(dbId);
const res = await fetch(apiUrl, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
});
if (!res.ok) return false;
return pWaitFor.resolveWith(
(await res.json()).connection_string
);
},
{ before: false, interval: 2e3 }
);
return connString;
}
export { createClaimableDatabase };