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

@house-agency/session-service

v1.2.1

Published

Session Service javascript consumer lib

Downloads

9

Readme

Session Service Client Lib

Build Status

  • Build: npm run build
  • Test: npm test
  • Integration tests: npm run integration <- this depends on Docker and Docker Compose

How to install

Simply run: npm i --save -E @house-agency/session-service

How to use

Create a new session

import {Session} from 'session-service';

const session = new Session(
  'https://session.service.com', // The HOST
  'api-key', // API KEY
  'some-secret', // API SECRET
  ['a-service', 'other-service'] // An array with services the session will be using
);

session.get()
  .then(response => {
    // response.token
    // response.services
    // response.data
  });

Reinstanciate an existing session

import {Session} from 'session-service';

const session = new Session(
  'https://session.service.com', // The HOST
  'api-key', // API KEY
  'some-secret', // API SECRET
  'session-token' // An existing session token instead of an array of services
);

session.get()
  .then(response => {
    // response.token
    // response.services
    // response.data
  });

Update a session with new data

import {Session} from 'session-service';

const session = new Session('https://session.service.com', 'api-key', 'some-secret', ['service']);

// When not using concurrency control - skip check for the newest version
session.update({some_key: 'value'})
  .then(response => {
    // response.token
    // response.services
    // response.data
  });

// When using concurrency control - this will throw an error if it's not the latest version
session.update({some_key: 'value'}, true)
// Concurrency control -------------^
  .then(response => {
    // response.token
    // response.services
    // response.data
  });
  .catch(error => console.log('Error: ', error.errorCode)); // Error: 412

Delete a session

import {Session} from 'session-service';

const session = new Session('session.service.com', 'api-key', 'some-secret', ['service']);

// When not using concurrency control - skip check for the newest version
session.remove()
  .then(token => {
    //
  });

// When using concurrency control - this will throw an error if it's not the latest version
session.remove(true)
  .then(token => {
    //
  })
  .catch(error => console.log('Error: ', error.errorCode)); // Error: 412

What is concurrencyControl?

If you're altering a session with an update or a deletion that has been changed somewhere else, then you'll have a concurrency problem to deal with. This session service library has two ways of dealing with this. Either you skip the concurrency control and the library will fetch the latest version of your session and alter that one. This is the default alternative. The other alternative is that you're writing code to deal with this yourself. You'll then add the concurrencyControl boolean in the update or remove methods and then have code to deal with the eventual catch.