Skip to content

Commit

Permalink
Config schema and clean-up, remove stacProxyUrl separated with ; in C…
Browse files Browse the repository at this point in the history
…LI, ... (#358)
  • Loading branch information
m-mohr authored Aug 16, 2023
1 parent bae5aa1 commit 4cdfc44
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 37 deletions.
3 changes: 1 addition & 2 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = {
],
apiCatalogPriority: null,
useTileLayerAsFallback: true,
tileSourceTemplate: null,
displayGeoTiffByDefault: false,
buildTileUrlTemplate: ({href, asset}) => "https://tiles.rdnt.io/tiles/{z}/{x}/{y}@2x?url=" + encodeURIComponent(asset.href.startsWith("/vsi") ? asset.href : href),
stacProxyUrl: null,
Expand All @@ -41,4 +40,4 @@ module.exports = {
requestQueryParameters: {},
preprocessSTAC: null,
authConfig: null
};
};
279 changes: 279 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
{
"$comment": "Defines a JSON Schema for the config file. Note that JS functions are specified as type 'null' with format 'function'.",
"type": [
"object"
],
"properties": {
"catalogUrl": {
"type": [
"string",
"null"
],
"format": "uri"
},
"catalogTitle": {
"type": [
"string"
]
},
"allowExternalAccess": {
"type": [
"boolean"
]
},
"allowedDomains": {
"type": [
"array"
],
"items": {
"type": [
"string"
]
}
},
"detectLocaleFromBrowser": {
"type": [
"boolean"
]
},
"storeLocale": {
"type": [
"boolean"
]
},
"locale": {
"type": [
"string"
]
},
"fallbackLocale": {
"type": [
"string"
]
},
"supportedLocales": {
"type": [
"array"
],
"items": {
"type": [
"string"
]
}
},
"apiCatalogPriority": {
"type": [
"string",
"null"
],
"enum": [
"collections",
"childs",
null
]
},
"useTileLayerAsFallback": {
"type": [
"boolean"
]
},
"displayGeoTiffByDefault": {
"type": [
"boolean"
]
},
"buildTileUrlTemplate": {
"type": [
"null"
],
"format": "function",
"noCLI": true,
"noEnv": true
},
"stacProxyUrl": {
"type": [
"array",
"null"
],
"prefixItems": [
{
"type": [
"string"
],
"format": "uri-reference"
},
{
"type": [
"string"
],
"format": "uri"
}
],
"items": false
},
"pathPrefix": {
"type": [
"string"
],
"buildOnly": true
},
"historyMode": {
"type": [
"string"
],
"enum": [
"history",
"hash"
],
"buildOnly": true
},
"cardViewMode": {
"type": [
"string"
],
"enum": [
"list",
"cards"
]
},
"cardViewSort": {
"type": [
"string",
"null"
],
"enum": [
"asc",
"desc",
null
]
},
"showThumbnailsAsAssets": {
"type": [
"boolean"
]
},
"stacLint": {
"type": [
"boolean"
]
},
"geoTiffResolution": {
"type": [
"integer"
],
"minimum": 1
},
"redirectLegacyUrls": {
"type": [
"boolean"
]
},
"itemsPerPage": {
"type": [
"integer"
],
"minimum": 1
},
"defaultThumbnailSize": {
"type": [
"array",
"null"
],
"minItems": 2,
"maxItems": 2,
"items": {
"type": [
"number"
]
}
},
"maxPreviewsOnMap": {
"type": [
"integer"
],
"minimum": 1
},
"crossOriginMedia": {
"type": [
"string",
"null"
],
"enum": [
"anonymous",
"use-credentials",
"",
null
]
},
"requestHeaders": {
"type": [
"object"
],
"noCLI": true,
"noEnv": false
},
"requestQueryParameters": {
"type": [
"object"
],
"noCLI": true,
"noEnv": true
},
"preprocessSTAC": {
"type": [
"null"
],
"format": "function",
"noCLI": true,
"noEnv": true
},
"authConfig": {
"type": [
"object"
],
"properties": {
"type": {
"type": [
"null",
"string"
],
"enum": [
"query",
"header"
]
},
"key": {
"type": [
"string"
]
},
"formatter": {
"oneOf": [
{
"type": [
"null"
],
"format": "function"
},
{
"type": [
"string"
],
"enum": [
"Bearer"
]
}
]
},
"description": {
"type": [
"string",
"null"
]
}
},
"noCLI": true,
"noEnv": true
}
}
}
2 changes: 1 addition & 1 deletion docs/local_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ npx http-server -p 8000 --cors

You can then use the CLI option `--catalogUrl="http://localhost:8000/catalog.json"` when starting STAC Browser.

If your catalog uses absolute file locations, you can use the [`stacProxyUrl`](options.md#stacproxyurl) option to convert local file locations to local web browser URLs. For instance, if you are serving a catalog on the local file system at `/home/user/catalog.json`, but want to serve the data out from a server located at `http://localhost:8000/`, you can use `--stacProxyUrl="/home/user;http://localhost:8000"`.
If your catalog uses absolute file locations, you can use the [`stacProxyUrl`](options.md#stacproxyurl) option to convert local file locations to local web browser URLs. For instance, if you are serving a catalog on the local file system at `/home/user/catalog.json`, but want to serve the data out from a server located at `http://localhost:8000/`, you can use `--stacProxyUrl=/home/user http://localhost:8000`.

## Using STAC Browser somewhere else

Expand Down
6 changes: 3 additions & 3 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Enables or disables a feature that validates the STAC catalog when opening the "
Validation uses the external service [staclint.com](https://staclint.com).

Validation is automatically disabled in the following cases:
- the host of a catalog is `localhost`, `127.0.0.1` and `::1`
- the host of a catalog is `localhost`, `127.0.0.1` or `::1`
- [private query parameters](../README.md#private-query-parameters) have been set
- `stacProxyUrl` is set

Expand Down Expand Up @@ -156,7 +156,7 @@ For instance, if you are serving a catalog on the local file system at `/home/us
the data out from a server located at `http://localhost:8888/`, you can use:

```bash
npm start -- --open --stacProxyUrl="/home/user;http://localhost:8888"
npm start -- --open --stacProxyUrl=/home/user http://localhost:8888
```

Notice the format of the value:
Expand Down Expand Up @@ -332,4 +332,4 @@ preprocessSTAC: (stac, state) => {
}
return stac;
}
```
```
9 changes: 0 additions & 9 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,6 @@ function getStore(config, router) {
state.catalogUrl = value;
}
break;
case 'stacProxyUrl':
// Proxy URLs coming from CLI have the form https://thingtoproxy.com;http://proxy:111
if (typeof value === 'string' && value.includes(';')) {
state[key] = value.split(';');
}
else {
state[key] = value;
}
break;
case 'crossOriginMedia':
state.crossOriginMedia = ['anonymous', 'use-credentials'].includes(value) ? value : null;
break;
Expand Down
Loading

0 comments on commit 4cdfc44

Please sign in to comment.