Intevel / gh-notifications

📬 Lightweight (<3KB) Wrapper around the GitHub Notifications API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gh-notifications

npm version npm downloads License

📬 Lightweight (<3KB) Wrapper around the GitHub Notifications API

Install

# Using npm
npm install gh-notifications

# Using yarn
yarn add gh-notifications

Usage

Warning: Usage of gh-notifications requires a valid github api token: Documentation

const APITOKEN = "**************";

async function main() {
  // get a GitHubInbox instance and pass the api token to it
  const inbox = new GitHubInbox(APITOKEN);
  // initialize the inbox
  await inbox.initialize();

  // fetch all unread notifications
  const unreadNotifications = await inbox.fetchUnreadNotifications();
  // view src/types.ts for all fields in the notification object
  console.log(unreadNotifications);

  // mark the latest unread notification as read
  await inbox.markAsRead(unreadNotifications[0]?.id);
}

main();

License

Published under MIT - Made with ❤️ by Conner Bachmann

About

📬 Lightweight (<3KB) Wrapper around the GitHub Notifications API

License:MIT License


Languages

Language:TypeScript 95.7%Language:JavaScript 4.3%