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

pk-client

v1.3.7

Published

A javascript(nodejs & browser) client library to talk to paysack and huepay apis.

Downloads

11

Readme

Paysack/Huepay client module

A javascript(nodejs & browser) client library to talk to paysack and huepay apis. See Docs

Install

npm install --save-dev pk-client

Usage

Authentication

import { SessionChallenge } from "pk-client";
let sc = new SessionChallenge('<base_api_url>', '[email protected]', 'password');


sc.login()
        .then(
            response => {
               console.log(response['token']);
            },
            err => {
                throw err;
            }
        );

REST API requests

import {ModelFactory,MODEL_PATHS} from "pk-client"; /*Typescript*/
// var  ModelFactory = require("pk-client").MODEL_PATHS;  /*Javascript*/
// var  MODEL_PATHS = require("pk-client").MODEL_PATHS; /*Javascript*/

let base_url = "https://<your-api-server></your-api-server>.com";
let mf = new ModelFactory({ api_base_url: base_url, token:"" });
try {
        let employee = await mf.anyModel(MODEL_PATHS.employees).get("me");
        let create_new = await mf.anyModel(MODEL_PATHS.employees).add({first_name:"abc",.....});
        let update_existing = await mf.anyModel(MODEL_PATHS.employees).put("5de6186d709db8cb2106812f",{first_name:"abc",.....});
    }
    catch (e) {
        console.log(e.toString());
        console.log(e.response.status);
    }

GraphQL requests


import {ModelFactory,GQL_PATHS} from "pk-client"; /*Typescript*/
// var  ModelFactory = require("pk-client").MODEL_PATHS;  /*Javascript*/
// var  GQL_PATHS = require("pk-client").GQL_PATHS; /*Javascript*/

let base_url = "https://<your-api-server></your-api-server>.com";
let token  = "<your_token>";

let mf = new ModelFactory({ api_base_url: base_url, token:"<your_token>" });
let gqlResult = await mf.gqlclient(`ms/graphql/comp-reports`).query('example_operation_1', {arg1:"value1",arg2:"value2"},'response_field_1 response_field_2');
let gqlResult = await mf.gqlclient(`ms/graphql/comp-reports`).mutation('example_operation_2', {arg1:"value1",arg2:"value2"},'response_field_1 response_field_2');

Fetch Passbook

let base_url = "https://<your-api-server></your-api-server>.com";
let token  = "<your_token>";

let mf = new ModelFactory({ api_base_url: base_url, token: token });

let timestamp_now = Date.now()/1000;
let timestamp_30_days_before = Date.now()/1000 - 30*24*60*60;

let passbook = await mf.passbookAdapter().fetch(  timestamp_now,
timestamp_30_days_before);

Fetch Employee/Member Details


let base_url = "https://<your-api-server></your-api-server>.com";
let token  = "<your_token>";

let mf = new ModelFactory({ api_base_url: base_url, token: token });

let employee = await mf.employees().get(`<_id>`);

let employee_all = await mf.employees().query({'pagination.limit':10,'pagination.field':'first_name','pagination.sort':'asc'}); //fetch all employees of a company

Fetch Logged-in User Details

const  MODEL_PATHS = require("pk-client").MODEL_PATHS;
let base_url = "https://<your-api-server></your-api-server>.com";
let token  = "<your_token>";

let mf = new ModelFactory({ api_base_url: base_url, token: token });

let user = await mf.anyModel(MODEL_PATHS.users).get('me');//fetches the logged in user

Running Tests

TEST_BASE_URL="https://base.url.com/" TEST_USERNAME="[email protected]" TEST_PASSWORD="xyzabcpqrs" npx intern

Building

Make sure you have browserify and uglify-js installed

npm install -g uglify-js
npm install -g browseify

Build client side libraries

npm run dist