Frameworks
Express.js — Intégration Scell.io
SDK TypeScript officiel @scell/sdk v3.5.0
Le SDK officiel `@scell/sdk` v3.5.0 (TypeScript-first, ESM + CJS) s'utilise dans Express.js comme un middleware ou directement dans les handlers. Types stricts auto-générés, support natif des promesses, retry exponentiel intégré, idempotency-key automatique sur les POST critiques. Compatible Node.js 20+ (LTS) et Bun.
À retenir
- Installation : `npm install @scell/sdk`
- TypeScript-first avec types auto-générés
- Singleton client dans `app.locals.scell`
- Retry exponentiel + idempotency intégrés
- Compatible Node.js 20 LTS et Bun
Exemple de code
import express from 'express';
import { ScellClient } from '@scell/sdk';
const app = express();
app.use(express.json());
const scell = new ScellClient({ apiKey: process.env.SCELL_API_KEY! });
app.post('/invoice', async (req, res) => {
const invoice = await scell.invoices.create({
format: 'factur-x',
buyer: { name: req.body.buyerName, is_individual: true },
lines: [{ description: req.body.label, quantity: 1, unit_price: req.body.amount, vat_rate: 20.0 }],
});
res.json({ id: invoice.id });
});
app.listen(3000);