npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wga-api

v0.2.2

Published

Service for the Window Gadgets Authenticator API.

Downloads

2

Readme

🏇 Authenticator API

User and team management for your app

Helper methods which may be used to access the Authenticator API using GraphQL.

Features

  • 🔥 Works in Node and on the browser.
  • ⚡️ Simple integration with React, Vue, and other browser libraries.
  • 👾 Write, send, and handle GraphQL queries.
  • 🏋️‍ Supports TypeScript and JavaScript.

Install

Using npm.

npm i --save wga-api

Using yarn.

yarn add wga-api

Setup

Start by importing the AuthenticatorAPI class.

import { AuthenticatorAPI } from 'wga-api'

A secret security key can be found in your Authenticator app settings.

const wga = new AuthenticatorAPI({
  secret: process.env.WGA_SECRET_KEY,
})

Note: use a package such as dotenv to securely store your secret variables.

Usage

Use the .create() method to create a new graphql dispatcher.

const retrieveUser = wga.create<{
  variables: {
    id: string,
  }
  data: {
    user: {
      id: string
      created: string
      updated: string
      name: string
      email: string
      username: string
      meta: { [key: string]: any }
    }
  }
}>({
  name: 'RetrieveUser',
  graphql: `
    query RetrieveUser($id: String) {
      user: RetrieveUser($id: string) {
        id
        created
        updated
        name
        email
        username
        meta
      }
    }
  `
})

Then use the .run(variables) method to send the graphql query.

retrieveUser.run({ id: '1234567890' })
  .then(data => {
    console.log(`User created at ${data.user.created}`)
  })
  .catch(error => {
    console.log(`An error occurred: ${error.message}`)
  })

Listen to all incoming dispatcher events with the .listen(data) method.

const unlisten = retrieveUser.listen(data => {
  console.log(`User created at ${data.user.created}`)
})

Below is an example of how the library can be used with React hooks.

const ShowUser = props => {
  const [user, setUser] = useState()
  useEffect(() => {
    return retrieveUser.listen(data => {
      setUser(data.user)
    })
  }, [])
  return (
    <div>
      <button onClick={() => retrieveUser.run({ id: props.id })}>
        Load User
      </button>
      <pre><code>{JSON.stringify(user, null, 2)}</code></pre>
    <div>
  )
}

Created with ❤️ by Window Gadgets.