Skip to main content

LFP Webhooks

Private package

LFP Webhooks is reserved for our projects and our partners: its repository is private and the package is not published on npm. This documentation presents it for those who have access.

LFP Webhooks receives the events of our Ligue 1 and Ligue 2 data service, built on opta-ftp-ws: goals, cards, substitutions, lineups, period changes, standings. A Discord bot subscribes to the events it cares about, and each handler gets a payload typed from the event name alone.

import { createReceiver } from '@fca.gg/lfp-webhooks'
import { listen } from '@fca.gg/lfp-webhooks/node'

const receiver = createReceiver({ secret: process.env.LFP_WEBHOOKS_SECRET })

receiver.on('match.goal', async ({ match, team, score, goal }) => {
await postGoal(match.matchId, goal.player?.showName, `${score.home} - ${score.away}`)
})

receiver.on('match.full_time', ({ match }) => closeThread(match.matchId))

await listen(receiver, 8080, { path: '/hooks/lfp' })

What it does​

  • Checks the signature x-lfp-signature-256 on the raw body, in constant time, or a Bearer token.
  • Answers before processing: the service gives up on a delivery after ten seconds and would replay it, which would produce a duplicate.
  • Drops replays thanks to the x-lfp-delivery delivery ID.
  • Runs handlers in a queue, in arrival order: two goals cannot overtake each other.
  • Infers the payload type from the event name.

Lightweight​

No dependencies. Each integration is a separate module (/node, /express, /fastify, /client) and the package is marked sideEffects: false: only what you import is loaded. The core only pulls node:crypto, and node:http is only loaded if you import /node. Types produce no code.

The package ships as ESM and CommonJS, for Node.js 18 or newer.

Going further​