El SDK
La API de Git desde código, y la verificación de webhooks, con @sypnia/git.
npm install @sypnia/gitimport { createClient } from '@sypnia/git/client';
const git = createClient({ token: process.env.SYPNIA_TOKEN });
const pr = await git.pulls.create('laespiga/web', {
head: 'cancel-order', base: 'main',
title: 'Los clientes pueden cancelar hasta las 10 am',
body: 'Case: cancel-order',
});
await git.statuses.create('laespiga/web', pr.headSha, { state: 'success', context: 'ci/tests' });import { verifyWebhook } from '@sypnia/git/webhooks';
const event = verifyWebhook(rawBody, headers, process.env.WEBHOOK_SECRET!);
if (event.type === 'pull_request' && event.action === 'closed' && event.pull_request.merged) {
// …
}Cada método corresponde a un endpoint de la API.