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 🙏

© 2025 – Pkg Stats / Ryan Hefner

termsinator

v1.4.0

Published

[![Build Status](https://travis-ci.org/ElderAS/termsinator.svg?branch=master&style=flat-square)](https://travis-ci.org/ElderAS/termsinator) [![npm](https://img.shields.io/npm/dt/termsinator.svg?style=flat-square)](https://www.npmjs.com/package/termsinator

Readme

termsinator

Build Status npm npm

Plugin to simplify consent management.

Requirements

This plugin is based on the following stack:

Installation

npm install --save termsinator

Usage

const Termsinator = require('termsinator')

/* This is the most simplest configuration, check out the docs for more features */
Termsinator.config({
  server: {
    endpoint: '/terms-and-conditions',
    host: 'https://myapp.com',
    instance: INSTANCE, // Express instance
    extractUser: function (req) {
      /* Must return a mongoose document with the same 
         type as defined in `database.schema` options */
      return req.user
    },
  },
  database: {
    schema: userSchema,
    setConsentOnCreate: function (doc) {
      return false
    },
  },
  ui: {
    logo: 'https://myapp.com/logo', //Path
    title: 'Avtalevilkår',
    termsLink: 'Les gjennom avtalevilkårene',
    termsCheckbox: 'Jeg godtar avtalevilkårene',
    submitButton: 'Send og godkjenn',
  },
  documents: JSON, // JSON -> containing all terms and conditions -> see doc
})

Config

You can configurate Termsinator anytime by calling:

Termsinator.config({
  /* Your config */
})

The following props are available for configuration:

server

Sets all necessary endpoints. It should look like this:

Termsinator.config({
  server: {
    endpoint: '/terms-and-conditions', // Your preferred endpoint for TAC management
    host: 'https://myapp.com', // Host address of your app
    instance: INSTANCE, // Express instance
    extractUser: function (req) {
      /* Must return a mongoose document with the same 
         type as defined in `database.schema` options */
      return req.user
    },
  },
})

database

Sets schema methods and hooks.

It should look like this:

Termsinator.config({
  database: {
    schema: userSchema, // Your user schema
    setConsentOnCreate: function (doc) {
      // Determine if consent should be set on creation, return true or false
      return false
    },
  },
})

IMPORTANT: If setConsentOnCreate === true, and the id on the document is a function, the request parameter is not supported and will be undefined

Termsinator will expose the following methods on all of your user documents:

userDocument.getConsent(req) -> return the current consent status and all historical consents

{
  current: {
    date: '...', // Date of consent action - null if no consent given
    status: '...', //Enum: ['accepted', 'declined', 'undetermined']
    document: '...', //Path to terms document
    metadata: {
      id: '...', // Document ID
      date: '...', // Document date
      message: '...', // Document message (Changelog)
    }
  },
  history: [CONSENT], // Array of historical consents (same as "current")
}

userDocument.setConsent() -> return the current consent status and all historical consents

userDocument.setConsent({
  id: '...', // Document ID to be consented
  status: '...', //Enum: ['accepted', 'declined']
})

ui

Set ui spesific properties like i18n, logo etc.

Example:

ui: {
  logo: 'https://myapp.com/logo',
  title: 'Avtalevilkår',
  termsLink: 'Les gjennom avtalevilkårene',
  termsCheckbox: 'Jeg godtar avtalevilkårene',
  submitButton: 'Send og godkjenn',
}

It is also possible to set ui with a function that has the request as first parameter. This allows for more dynamic content.

Example:

ui: req => {
  // Do something like language resolving etc
  return {
    logo: 'https://myapp.com/logo',
    title: 'Avtalevilkår',
    termsLink: 'Les gjennom avtalevilkårene',
    termsCheckbox: 'Jeg godtar avtalevilkårene',
    submitButton: 'Send og godkjenn',
  }
}

documents

Manage your terms & conditions, add new terms etc.

// Document object
{
	id: {String},
	document: {String},
	date: {String},
	// optional
	external: {Boolean},
	message: {String}
}

If external === true, the document property will be treated as a URL, not a path on disk

All values on the document object can be replaced by a function that returns the expected value type. The function will recieve the express request object as parameter

Example:

;[
  {
    id: '1.0.0',
    document: '/terms/Terms-1-0-0.pdf', // Relative path (from project root) to file on disk
    date: '2018-11-01T14:29:24.811Z',
  },
  {
    id: function (req) {
      return req.client.term.id // This has to be a string
    },
    document: '/path/to/external/api',
    external: true,
    message: 'Changes in usage of user properties',
    date: '2018-11-01T15:29:24.811Z',
  },
]

License

The MIT License Copyright (c) Carsten Jacobsen