Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

addok-cluster

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

addok-cluster

Clustering addok geocoding capabilities from your Node.js process

  • 0.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
increased by166.67%
Maintainers
0
Weekly downloads
 
Created
Source

addok-cluster

npm node-current Coverage Status Libraries.io dependency status for latest release

A very fast and efficient way to use addok geocoding capabilities in your Node.js process.

Features

  • Manage multiple addok nodes
  • Fluent JavaScript API
  • 30% more efficient than HTTP calls
  • Fast priority queue (high, medium, low)
  • Supports AbortController
  • Auto-restart nodes
  • Handle multiple Redis databases (round robin)
  • Managed Redis server (optional)

Prerequisites

  • Node.js 18 LTS and above
  • Be able to use ESM
  • A working environment for addok (Python, Redis, dependencies…)

Install

npm install addok-cluster

Configure

import {createCluster} from 'addok-cluster'

const cluster = await createCluster(options)
Environment variable nameOption nameDescription
PYTHON_PATHpythonPathPath to python executable to use
ADDOK_CLUSTER_NUM_NODESnumNodesNumber of nodes to instantiate (default to number of CPUs)
ADDOK_CONFIG_MODULEaddokConfigModulePath to addok configuration file
ADDOK_REDIS_URLaddokRedisUrlConnection string to addok Redis instance (can be an array)
ADDOK_REDIS_DATA_DIRredisDataDirPath to Redis data directory (enable managed Redis)
ADDOK_REDIS_STARTUP_TIMEOUTredisStartupTimeoutDuration in milliseconds allowed to Redis to start (managed Redis only)

Use

Geocode

const params = {
  q: '1 rue de la paix 75002 Paris',
  autocomplete: false,
  lon: null,
  lat: null,
  limit: 5,
  filters: {
    postcode: '75002',
    citycode: '75102'
  }
}

const options = {
  priority: 'medium',
  signal: null
}

const results = await cluster.geocode(params, options)
ParamDescriptionDefault
qText input to geocode (required)
autocompleteAuto-complete mode (boolean)false
lon, latCoordinates of reference position
limitNumber of returned results5
filtersAdditional filters (depend on addok config){}

Reverse geocode

const params = {
  lon: null,
  lat: null,
  limit: 5,
  filters: {
    type: 'housenumber'
  }
}

const options = {
  priority: 'high',
  signal: null
}

const results = await cluster.reverse(params, options)
ParamDescriptionDefault
lon, latCoordinates of reference position (required)
limitNumber of returned results5
filtersAdditional filters (depend on addok config){}

Options

priority: low | medium (default) | high

Define the priority level of the request. Requests are processed following FIFO rule, from high to low.

signal: AbortSignal instance (optional)

If an AbortSignal instance is provided, its status is checked just before forwarding to addok.

Stop cluster

cluster.end()

Sponsorship

This software is maintained by Living Data, thanks to the support of partners such as Etalab (API Adresse) and IGN (Géoplateforme).

FAQs

Package last updated on 23 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc