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

iop-connector

v3.4.3

Published

Module to connect to an ETRA Interoperability Platform via DDP or HTTP

Downloads

6

Readme

IOP Connector

Module to connect to an ETRA Interoperability Platform via DDP or HTTP:

  • IOP. Extends SimpleDDP and provides methods to interact with an ETRA Interoperability Platform via DDP.
  • IOPHTTP. Provides methods to interact with an ETRA Interoperability Platform via HTTP.

Usage

Install the package running:

npm install iop-connector

DDP connector

Available methods:

| Method | Parameters | Description | |---|---|---| | login | user, password | Authentication via user name and password. Returns an object with the fields userId, token and tokenExpires | | loginApp | appId, keyId | Authentication via appId and keyId for application-type users | | renewToken | | Renew authentication token (only needed for regular users) | | isLogged | | Returns whether the user is logged in or not | | findAll | collection, selector | Query documents from a collection | | insert | collection, data | Insert one or multiple documents. data can be an array of documents | | update | collection, data | Update one or multiple documents. data can be an array of documents | | remove | collection, selector | Delete all the matching documents (Use carefully!) | | findOne | collection, id | Get a single document |

All methods accept a callback as a last parameter or return a Promise if not provided. Note that the parameter "collection" would be in the form of layer_collection.

DDP example

import { IOP } from 'iop-connector';
// or const { IOP } = require('iop-connector');

async function start() {
  // Initialize the connection
  const server = IOP('https://your.server.com');

  // Login as a regular user
  const userLogin = await server.login('<username>', '<password>');
  console.log(userLogin.tokenExpires); // "2020-07-28T11:49:06.455Z"

  // Or login as an application (in case you are provided with credentials in the form of appId and keyId)
  await server.loginApp('<appId>', '<keyId>');

  // Subscribe to the desired data. Creating the corresponding subscriptions is mandatory in order to obtain the data
  const subscription = server.subscribe('<layer>_<collection>.all');
  await subscription.ready();

  // Retrieve the desired data
  const allItems = await server.findAll('<layer>_<collection>');
  const oneItem = await server.findOne('<layer>_<collection>', '<item_id>');

  // Remove one element
  await server.remove('<layer>_<collection>', { _id: '<item_id>' });

  // Manage the token renovation when needed
  await server.renewToken();
}

start();

HTTP connector

Available methods:

| Method | Parameters | Description | |---|---|---| | health | | Check the server availability | | login | user, password | Authentication via user name and password | | loginApp | appId, keyId | Authentication via appId and keyId for application-type users | | renewToken | | Renew authentication token (only needed for regular users) | | me | | Get logged user ID and profile | | get | layer, collection, selector | Query documents from a collection | | add | layer, collection, data | Insert one or multiple documents. data can be an array of documents | | mod | layer, collection, data | Update one or multiple documents. data can be an array of documents | | del | layer, collection, selector | Delete all the matching documents | | getOne | layer, collection, id | Get a single document | | modOne | layer, collection, id, data | Update a document. data is an object with the changes to be applied | | delOne | layer, collection, id | Delete a document | | range | layer, collection, data | Query documents on a range of dates. data is an object with the fields from, to and field (if the field in which to compare the dates is different than timestamp) | | near | layer, collection, data | Query documents near a geographic point. data is an object with the fields lat, lon and distance |

All methods accept a callback as a last parameter or return a Promise if not provided. The response is an object with the fields status (that should be "success") and data.

HTTP example

import { IOPHTTP } from 'iop-connector';
// or const { IOPHTTP } = require('iop-connector');

async function start() {
  // Initialize the connection
  const server = IOPHTTP('https://iop.server.com');

  // Login
  await server.login('<username>', '<password>');

  // Retrieve the desired data
  const allItems = await server.get('<layer>', '<collection>');
  const oneItem = await server.getOne('<layer>', '<collection>', '<item_id>');

  // Manage the token renovation if needed
  await server.renewToken();
}

start();

If you are provided with application credentials in the form of appId and keyId, there are two options to manage the authentication:

  1. Pass your credentials when initializing the connector:
const server = IOPHTTP('https://your.server.com/api/v2', '<appId>', '<keyId>');
  1. Use the loginApp method:
server.loginApp('<appId>', '<keyId>')

Note that it is a synchronous method so doesn't accept a callback nor return a Promise.