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/oai-pmh

v0.0.3

Published

Simple client library for OAI-PMH

Downloads

20

Readme

@indexdata/oai-pmh

Copyright (C) 2022 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

This is a very simple OAI-PMH client library, written because all the various existing libraries known to Node are abandonware or undocumented.

It exists primarily for the use of ui-harvester-admin but should be of wider utility.

API

First, create an OAI-PMH client object associated with a specific service:

import OaiPmh from '@indexdata/oai-pmh';
const oaiPmh = new OaiPmh('https://ora.ox.ac.uk/oai2');

Now you can use it to ask the server to identify itself, supply a list of sets, etc:

const identity = await oaiPmh.identify();
const sets = await oaiPmh.listSets();
const formats = await oaiPmh.listMetadataFormats();

At present, only the Identify, ListSets and ListMetadataFormat verbs are supported: we will add others as we have a need for them. The optional parameters to the second and third of these are ignored.

All methods return a promise that resolves to a JavaScript object containing the data returned from the service. So for example:

formats.ListMetadataFormats[0].metadataFormat.map(x => {
  console.log(`prefix '${x.metadataPrefix} -> ${}`);
});

See the very simple example code.

Note on dependencies

The package file includes a dependencies on timers and stream even though we don't use those packages directly. This is because the xml2js library needs them but doesn't have dependencies, probably because it's relying on the behavior of Babel before v5.x which used to polyfill various node.js core modules.

Of CORS security is an issue

Understandably, when a browser loads the FOLIO SPA from one origin, it's unhappy about letting that SPA make OAI-PMH requests (or any HTTP requests) to other origins. We will need to figure out a way to address this in production, but for development it suffices to use the local-cors-anywhere web proxy. Install globally with yarn global add local-cors-anywhere and run as env PORT=8081 ~/.yarn/bin/local-cors-anywhere. Then prefix OAI-PMH service URLs with http://localhost:8081/, so that the SPA accesses services at URLs like http://localhost:8081/https://ora.ox.ac.uk/oai2