Frameworks
Deno Fresh — Scell.io integration
@scell/sdk via npm: + Fresh handlers
The `@scell/sdk` v3.5.0 SDK works in Deno (>= 1.40) via the `npm:@scell/sdk` specifier (or `jsr:` when published). Use only in Fresh handlers (server-side) or API routes (`routes/api/*.ts`). Env vars via `Deno.env.get("SCELL_API_KEY")`. Compatible with Fresh 1.6+ and Deno Deploy.
Key facts
- Import: `import { ScellClient } from 'npm:@scell/sdk'`
- Only in server handlers or `routes/api/*`
- `Deno.env.get('SCELL_API_KEY')` (never client-side)
- Compatible with Fresh 1.6+ and Deno Deploy
- Permissions: `--allow-net --allow-env`
Code example
// routes/api/invoice.ts
import { Handlers } from '$fresh/server.ts';
import { ScellClient } from 'npm:@scell/sdk';
const scell = new ScellClient({ apiKey: Deno.env.get('SCELL_API_KEY')! });
export const handler: Handlers = {
async POST(req) {
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 });
},
};