@pipilot/server
v0.3.1
Published
Server-side SDK for PiPilot Cloud, the PiPilot managed backend (database, storage, secrets). Uses a project service key — server-side only.
Maintainers
Readme
@pipilot/server
Server-side SDK for PiPilot Cloud, the PiPilot managed backend — database, storage, and secrets for any app, on any stack, with zero infra to run. Provision a backend in one call and talk to it through PiPilot's gateway.
Server-side only. The service key grants full access to your project's data (like a Supabase service role key). Never ship it to a browser. A browser SDK with row-level policies (the anon key) ships separately.
Install
npm install @pipilot/serverUsage
import { createClient } from '@pipilot/server';
const db = createClient(process.env.PIPILOT_SERVICE_KEY);
// Insert (tables are created implicitly)
await db.from('todos').insert({ text: 'Ship it', done: false });
// Read
const todos = await db.from('todos').select({ limit: 20 });
// Update (replaces the whole record) / delete by id
await db.from('todos').update(todos[0].id, { ...todos[0], done: true });
await db.from('todos').delete(todos[0].id);
// Storage
await db.storage.upload('invoices/2026.pdf', pdfBuffer, { contentType: 'application/pdf' });
const files = await db.storage.list();
const file = await db.storage.download('invoices/2026.pdf'); // { contentType, base64, bytes, text() }
const url = await db.storage.getUrl('invoices/2026.pdf', 600); // temporary signed URL
await db.storage.remove('invoices/2026.pdf');
// Secrets (names only — values are set in the PiPilot dashboard)
const secretNames = await db.secrets.list();
// Functions — invoke a serverless function you deployed to this backend
const result = await db.functions.invoke('checkout', { plan: 'pro' });
// Runtime features — keyless, no third-party accounts
const { text } = await db.ai.generate({ prompt: 'Summarize this order' });
await db.notifications.sendToTopic({ topic: 'alerts', notification: { title: 'Sale', body: '50% off' } });
const invite = await db.invites.create({ resourceType: 'room', authMode: 'anonymous' });
await db.realtime.send(connectionIds, { type: 'update', data });Getting a service key
Create a project (once) from your PiPilot account — it provisions a managed backend and returns a
pk_live_… service key, shown only once. Store it as PIPILOT_SERVICE_KEY.
API
createClient(serviceKey, { url?, fetch? })db.from(table).select({ limit?, filter? })→Row[]db.from(table).insert(record | record[])→{ ids }db.from(table).update(id, record)→{ success }db.from(table).delete(id)→{ success }db.storage.list()→string[]db.storage.upload(path, content, { contentType? })— content:string | Buffer | Uint8Array | ArrayBufferdb.storage.download(path)→{ path, contentType, base64, bytes, text() }db.storage.getUrl(path, expiresIn?)→ signed URLstringdb.storage.remove(path)→{ success }db.secrets.list()→string[]db.functions.invoke(name, body?)→ the function's JSON responsedb.ai.generate/extract/classify/ocr/run/imageGen(opts)— keyless platform AIdb.notifications.send/sendToTopic/subscribeTopic/unsubscribeTopic/listUserTopics(opts)db.invites.create/resolve/join/revoke(opts)db.realtime.send(connectionIds, payload)
