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

@koopjs/koop-core

v10.4.8

Published

Serve, transform, and query geospatial data on the web

Downloads

1,302

Readme

Koop

npm version coverage

Transform, query, & download geospatial data on the web. See koopjs.github.io for details.

This is the core dependency for setting up a Koop instance. By default it includes the Output-Geoservices plugin and an in-memory data cache.

Install

# Install Koop npm and save to package.json
npm install --save @koopjs/koop-core

Usage

The Koop usage docs and quick start provide usage information, but we'll give a quick overview here.

// require koop-core
const Koop = require('@koopjs/koop-core')

// create a Koop instance
const koop = new Koop(options)

/* Register Koop data providers */
const provider = require('@koopjs/provider-github')
koop.register(provider)


// Start listening on port 8080
koop.server.listen(8080, () => console.log(`Koop listening on port 8080!`))

Every Koop instance includes the Geoservice output-plugin by default, so after startup noted above, you would have the following routes ready to receive requests: [GET, POST] /github/rest/info [GET, POST] /github/rest/services/:id/FeatureServer/:layer/:method [GET, POST] /github/rest/services/:id/FeatureServer/layers [GET, POST] /github/rest/services/:id/FeatureServer/:layer [GET, POST] /github/rest/services/:id/FeatureServer

Options

You can pass an options object when instantiating a Koop instance.

// create a Koop instance
const koop = new Koop(options)

disableCors

Koop enables CORS by default. If you do not want CORS enabled, you can disable it by adding a disableCors boolean to your Koop config file:

const options = {
  disableCors: true
}

disableCompression

Koop adds Express compression by default. If you do not want Express compression (e.g., perhaps you are using Nginx for compression), you can disable it by adding a disableCompression boolean to your Koop config file:

const options = {
  disableCompression: true
}

logger

Koop includes a Winston logger with a console transport by default. If you have a custom logger that you want to use, you can pass it as an option:


const logger = require('my-logger')
const options = {
  logger
}

logLevel

The default Koop logger uses a log-level of info. If you want to change the log level, you can pass any of the standard Winston log-level values as an option:

const options = {
  logLevel: 'debug'
}

cacheSize

The maximum number of items to store in the default memorey-cache. Defaults to 500:

const options = {
  cacheSize: 1000
}

skipGeoservicesRegistration

By default, Koop will register the GeoServices output-plugin (a.k.a. FeatureServer). If you do not want this plugin registered or want to register a specific version, you can skip the default registration by setting the option to true:

const options = {
  skipGeoservicesRegistration: true
}

geoservicesDefaults

Koop registers the Geoservices output plugin (FeatureServer) by default. This plugin takes its own options including those to set server and layer metadata (e.g., FeatureServer version, copyrightText, maxRecordCount, etc). These are useful for overriding defaults set in the FeatureServer codebase. You can have Koop set these options at start-up by passing the geoservicesDefaults option. It should be a JSON object with the specification described in the FeatureServer documentation.

Registering Providers

When registering a provider you can pass an options object that provides some useful functionality:

const Koop = require('@koopjs/koop-core')
const koop = new Koop()

const providerOptions = {
  name: 'special-name',
  cacheTtl: 600,
  before: (req, callback) => {
    req.query.myHardCodedParam = 'foo';
    callback();
  }
  after: (req, geojson, callback) => {
    geojson.crs = 'my coordinate system';
    callback(null, geojson);
  }
}

/* Register Koop data providers with options */
const provider = require('@koopjs/provider-github')
koop.register(provider, providerOptions)

Provider registration options

name

Use this param to override the name of the provider. If you supply a value for name it will be used in the path for routes registered to this provider.

cacheTtl

Use this param to set the default caching time (in seconds) for any data acquired by this provider. It can be overridden on a request-by-request basis by adding a ttl property to the root level of the geojson produced by the provider.

before

Supply a function that is executed before a provider's getData method and has access to the Express request object. This is useful is you want to modify incoming request params before they arrive in a providers getData method.

after

Supply a function that is executed after a provider's getData method and has access to the Express request object. This is useful is you want to modify the GeoJSON produce by the provider before it is passed on to the cache or any output plugin. It's a way of modifying a provider's getData functionality without having to modify the code of the provider itself.

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

License

Apache 2.0