@untypeable/logsnag
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

📱 @untypeable/logsnag

Untypeable router type definitions & validators for the LogSnag API

🚀 Install

Install it locally in your project

# npm
npm install @untypeable/logsnag

# yarn
yarn add @untypeable/logsnag

# pnpm
pnpm install @untypeable/logsnag

🦄 Usage

Create a new client instance with the LogSnagRouter & your desired fetch handler

import { createTypeLevelClient } from "untypeable";

import type { LogSnagRouter } from "@untypeable/spacex";

const client = createTypeLevelClient<LogSnagRouter>(
  (path, { apiVersion = "v1", ...input }) =>
    fetch(`https://api.logsnag.com/${apiVersion}/${path}`, {
      body: JSON.stringify(input),
      headers: {
        Authorization: `Bearer ${process.env.LOGSNAG_API_KEY}`,
        "Content-Type": "application/json",
      },
      method: "POST",
    }).then((res) => res.json())
);

const log = await client("/log", {
  channel: "waitlist",
  event: "User Joined",
  icon: "🎉",
  tags: {
    name: "john doe",
    email: "john@example.com",
  },
  notify: true,
});

const insight = await client("/insight", {
  title: "User Count",
  value: "100",
  icon: "👨",
});

Package Sidebar

Install

npm i @untypeable/logsnag

Homepage

logsnag.com

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

8.5 kB

Total Files

9

Last publish

Collaborators

  • nurodev