This is an example that demonstrates how to build a Koop Provider. You can clone this project, and use it to start a new provider. This sample can run a local server, deploy to AWS Lambda or Docker for testing and operations. Once the provider is published to NPM, then it can be used with other Koop providers and outputs in a larger project.
The data source in this example is the TriMet Bus API. You can see this provider in action here.
Full documentation is provided here.
- Open
config/default.json
with any configurable parameters - Open
src/index.js
and changeprovider.name
to a unique name - Open
src/model.js
and implementgetData
to call your provider and return GeoJSON - Install dependencies
npm install
- Run a local dev server
npm start
- Add tests to
test/
File | Description | |
---|---|---|
src/index.js |
Mandatory | Configures provider for usage by Koop |
src/model.js |
Mandatory | Translates remote API to GeoJSON |
src/routes.js |
Optional | Specifies additional routes to be handled by this provider |
src/controller.js |
Optional | Handles additional routes specified in routes.js |
test/model-test.js |
Optional | tests the getData function on the model |
test/fixtures/input.json |
Optional | a sample of the raw input from the 3rd party API |
config/default.json |
Optional | used for advanced configuration, usually API keys. |
Run server:
npm install
npm start
Example API Query:
curl localhost:8080/example/FeatureServer/0/query?returnCountOnly=true
Tests:
npm test
During development you can output error callstack with
NODE_ENV=test npm start
- run
npm init
and update the fields- Choose a name like
koop-provider-foo
- Choose a name like
- run
npm publish