Aller au contenu principal

Frameworks

Bun — Intégration Scell.io

@scell/sdk + fetch natif Bun (zero-config)

Le SDK `@scell/sdk` v3.5.0 fonctionne nativement dans Bun (>= 1.1) via `bun add @scell/sdk`. Bun supporte `Bun.serve()` comme alternative ultra-performante à Express : démarrage en <50ms, fetch natif (pas de polyfill). Variables d'environnement via `Bun.env.SCELL_API_KEY` ou `process.env`. Idéal pour APIs serverless ou edge.

À retenir

  • Installation : `bun add @scell/sdk`
  • `Bun.serve()` natif, démarrage <50ms
  • Fetch natif Bun (HTTP/2 + keep-alive)
  • `Bun.env.SCELL_API_KEY` ou `process.env`
  • Compatible Bun 1.1+, idéal serverless/edge

Exemple de code

import { ScellClient } from '@scell/sdk';

const scell = new ScellClient({ apiKey: Bun.env.SCELL_API_KEY! });

Bun.serve({
  port: 3000,
  async fetch(req) {
    if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 });
    const { buyer, amount } = await req.json();
    const invoice = await scell.invoices.create({
      format: 'factur-x',
      buyer: { name: buyer, is_individual: true },
      lines: [{ description: 'Service', quantity: 1, unit_price: amount, vat_rate: 20.0 }],
    });
    return Response.json({ id: invoice.id });
  },
});

Voir aussi

Vos préférences cookies

Nous utilisons des cookies pour améliorer votre expérience. Les cookies essentiels sont toujours actifs. Politique cookies.