SDK Node.js
Instalación
npm i @starcore/sdk-nodeUso
import { StarCore } from '@starcore/sdk-node';
const sc = new StarCore({ apiKey: process.env.STARCORE_KEY! });
const result = await sc.ecf.emit({ xml: '<ECF>...</ECF>',});
console.log(result.trackId);Handlers de webhooks
import express from 'express';import { verifyWebhook } from '@starcore/sdk-node';
const app = express();app.post('/webhooks/starcore', express.raw({ type: '*/*' }), (req, res) => { const ok = verifyWebhook({ body: req.body.toString('utf8'), signature: req.header('x-starcore-signature')!, timestamp: req.header('x-starcore-timestamp')!, secret: process.env.STARCORE_WEBHOOK_SECRET!, }); if (!ok) return res.status(400).end(); const event = JSON.parse(req.body.toString('utf8')); console.log('event:', event.type); res.status(200).end();});