Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 824 Bytes

File metadata and controls

50 lines (39 loc) · 824 Bytes

Quickstart

1. Install

npm install @apinator/server

2. Initialize

import { Apinator } from "@apinator/server";

const client = new Apinator({
  appId: process.env.APINATOR_APP_ID!,
  key: process.env.APINATOR_KEY!,
  secret: process.env.APINATOR_SECRET!,
  cluster: "eu",
});

3. Trigger events

await client.trigger({
  name: "message-created",
  channel: "chat-room-1",
  data: JSON.stringify({ text: "Hello" }),
});

4. Authenticate private/presence subscriptions

const auth = client.authenticateChannel(
  socketId,
  "presence-chat",
  JSON.stringify({ user_id: "u1", user_info: { name: "Alice" } })
);

5. Verify webhooks

const isValid = client.verifyWebhook(
  req.headers as Record<string, string | string[] | undefined>,
  rawBody,
  300
);