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

@lblod/ldes-producer

v0.7.2

Published

A time fragmenter library for LDES

Downloads

392

Readme

LDES Producer library

Usage

npm install @lblod/ldes-producer

Get Node

import {
  getNode as getNodeFn,
  addData as addDataFn,
  getConfigFromEnv,
  ACCEPTED_CONTENT_TYPES,
} from '@lblod/ldes-producer';

const config = getConfigFromEnv();

try {
  const contentType = req.accepts(ACCEPTED_CONTENT_TYPES) || '';

  const result = await getNodeFn(config, {
    folder: req.params.folder,
    contentType: contentType,
    nodeId: parseInt(req.params.nodeId ?? '1'),
    resource: req.params[0] || '',
  });

  if (result.fromCache) {
    res.header('Cache-Control', 'public, immutable');
  }

  res.header('Content-Type', contentType);

  result.stream.pipe(res);
} catch (e) {
  return next(e);
}

Add data

try {
  const contentType = req.headers['content-type'] as string;
  await addDataFn(config, {
    contentType,
    folder: req.params.folder,
    body: req.body,
    fragmenter: req.query.fragmenter as string,
  });

  res.status(201).send();
} catch (e) {
  return next(e);
}

Configuration

The following environment variables can be set:

  • BASE_URL (required): the base-url on which this service is hosted. This ensures the service can resolve relative urls.
  • DATA_FOLDER: the parent folder to store the LDES streams in. (default: /data)
  • LDES_STREAM_PREFIX: the stream prefix to use to identify the streams. This prefix is used in conjunction with the folder name of the stream. (default: http://mu.semte.ch/streams/)
  • TIME_TREE_RELATION_PATH: the path on which the relations should be defined when fragmenting resources using the time-fragmenter. This is also the predicate which is used when adding a timestamp to a new version of a resource. (default: http://www.w3.org/ns/prov#generatedAtTime)
  • PREFIX_TREE_RELATION_PATH: the path on which the relations should be defined when fragmenting resources using the prefix-tree-fragmenter. (default: https://example.org/name)
  • CACHE_SIZE: the maximum number of pages the cache should keep in memory. (default: 10)
  • FOLDER_DEPTH: the number of levels the data folder structure should contain. (default: 1, a flat folder structure)
  • PAGE_RESOURCES_COUNT: the number of resources (members) one page should contain. (default: 10)
  • SUBFOLDER_NODE_COUNT: the maximum number of nodes (pages) a subfolder should contain. (default: 10)
  • LDES_PRODUCER_LOG_LEVEL: if set to "debug", will log some debug informations