Skip to content

Commit

Permalink
Merge pull request #1 from koopjs/f/6769-ogc-hub-search
Browse files Browse the repository at this point in the history
F/6769 Stream ogc items from ogc hub search api
  • Loading branch information
sansth1010 authored May 30, 2023
2 parents 1e093bd + c823556 commit 7580482
Show file tree
Hide file tree
Showing 34 changed files with 7,232 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false

[*.{js,jsx,json,ts,tsx,yml}]
indent_size = 2
indent_style = space
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/**/*.js
29 changes: 29 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"env": {
"browser": false,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"ignorePatterns": ["src/**/*.test.ts"],
"plugins": ["@typescript-eslint", "jest"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-explicit-any": "off",
"jest/expect-expect": "off",
"semi": [2, "always"]
}
}
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Logs
logs
*.log
npm-debug.log*

# Dependencies
node_modules/

# Coverage
coverage

# Transpiled files
build/

# VS Code
.vscode
!.vscode/tasks.js

# JetBrains IDEs
.idea/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Misc
.DS_Store
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"singleQuote": true,
"trailingComma": "all",
"overrides": [
{
"files": "*.ts",
"options": {
"parser": "typescript"
}
}
]
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# CHANGELOG.md

## Unreleased

Added
- Initial release for OGC Hub Search API Koop Provider
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2023 Esri

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Koop Provider Hub Search OGC

![Coverage](./coverage.svg)

This is a Koop provider that extracts datasets from the ArcGIS Hub Search OGC API.

## Use - Streaming All Datasets
This provider plugin currently only supports [streaming](https://nodejs.org/api/stream.html#stream_readable_streams) ALL datasets matching a given search query.

### Define Search Parameters
To perform a search from an output plugin, attach onto the response.
```js
req.res.locals.siteIdentifier = 'https://my-site.hub.arcgis.com'
```


### Pull the Readable Stream
Then pass the request object to `this.model.pullStream`.
```js
const docStream = await this.model.pullStream(req);
```

### Full Example
What you have now is a Node.js `Readable` stream. You can pipe the datasets from the readable through a transform stream in order to format them into some other type of output before sending them back to the browser by piping them to the Express.js response. The following simple example also uses the [`through2`](https://www.npmjs.com/package/through2) library to conveniently define a transform stream.

```js
async handleRequest (req, res) {
req.res.locals.siteIdentifier = 'my-site.hub.arcgis.com'

const docStream = await this.model.pullStream(req);

docStream
.pipe(through2.obj(function (dataset, enc, callback) {
const transformed = someTranformFunc(dataset);

// the Express.js "res" Writable only accepts strings or Buffers
this.push(JSON.stringify(transformed));
callback();
}))
.pipe(res);
}
```

## Develop
```sh
# clone and install dependencies
git clone https://github.com/koopjs/koop-provider-hub-search-ogc
cd koop-provider-hub-search-ogc
npm i

# starts the example Koop app found in ./example-app.
npm run dev
```

## Test
Run the `npm t` commmand to spin up the automated tests.
8 changes: 8 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
On branch `main`
- bump version in `package.json`
- run `npm i` to update `package-lock.json`
- if it exists, update "Unreleased" header in `CHANGELOG.md` to the new version number
- commit with a message `:package: <version-number>`. (example `":package: 1.0.2"`)
- push the commit to `main`
- run [`gh-release`](https://github.com/hypermodules/gh-release) (may need to install)
- `npm run release`
20 changes: 20 additions & 0 deletions coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions example-app/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2023 Esri

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

> http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
3 changes: 3 additions & 0 deletions example-app/config/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"port": "8080"
}
3 changes: 3 additions & 0 deletions example-app/koop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "app"
}
Loading

0 comments on commit 7580482

Please sign in to comment.