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

@indexdata/foliojs

v1.1.0

Published

Simple client library for the FOLIO library services platform

Downloads

2

Readme

@indexdata/foliojs

Copyright (C) 2023 Index Data Aps.

This software is distributed under the terms of the Apache License, Version 2.0. See the file "LICENSE" for more information.

Overview

FolioJS is a simple Node library to allow the creation of scripts that manipulate instances of the FOLIO library services platform. For example, a very simple program to list the first 20 usernames, with asterisks next to the active ones, might read as follows:

import Folio from '@indexdata/foliojs';

const service = Folio.service('https://folio-snapshot-okapi.dev.folio.org');
const session = await service.login('diku', 'user-basic-view', 'user-basic-view');
const body = await session.folioFetch('/users?limit=20');
console.log(body.users.map(u => `${u.active ? '*' : ' '} ${u.username}`).join('\n'));
session.close();

Other applications might include:

How to use this library

(People who are already familiar with Node ecosystem can skip this part.)

  1. Create an area for the project that's going to use FolioJS.
  2. In that area, make a package.json file that specifies type as module and has a dependency that provides the @indexdata/foliojs library (see below).
  3. Write your program, including FolioJS library with import Folio from '@indexdata/foliojs'.

The dependency on this library can be expressed numerically, in which case a corresponding released version will be used; or it can be expressed as a GitHub repository name, in which case the current version will be used. At present, no release has yet been made, so the latter approach must be used. So for example the following package.json can be used:

{
  "type": "module",
  "dependencies": {
    "@indexdata/foliojs": "MikeTaylor/foliojs"
  }
}

API

The API is described in a separate document, The FolioJS API.

Environment

The behaviour of the FolioJS library can be modified by the values of the following environment variables:

  • LOGGING_CATEGORIES or LOGCAT -- see Logging below.
  • FOLIOJS_OLD_AUTH -- if defined and set to a truthy value such as 1, new-style (cookie-based) authentication is not used, only old-style (Okapi token-based) authentication.
  • FOLIOJS_SESSION_TIMEOUT -- if defined, the number of seconds after which a new session cookie will be requested. (If not defined, the default is to request a new cookie after half of the lifetime of the old one, which is typically about ten minutes.)

Logging

This library uses the tiny but beautiful categorical-logger library to provide optional logging. This is configured at run-time by the LOGGING_CATEGORIES or LOGCAT environment variable, which is set to a comma-separated list of categories such as op,curl,status. Messages in all the listed categories are logged.

Apart from categories used by log invocations in application code, the following categories are used by the libarary itself:

  • op: whenever a high-level Okapi operation is about to be executed, its name and parameters are logged.
  • auth: emits messages when authenticating or re-authenticating a session.
  • curl: whenever an HTTP request is made, the equivalent curl command is logged. This can be useful for reproducing bugs.
  • status: whenever an HTTP response is received, its HTTP status and content-type are logged. The combination of op,status is useful for tracing what a program is doing.
  • response: whenever an HTTP response is received, its content is logged.

Author

Mike Taylor ([email protected]), for Index Data Aps.