A simple Node.js Express server implementing a STAC (SpatioTemporal Asset Catalog) API for testing authentication mechanisms in STAC Browser.
-
Install dependencies:
npm install
-
Configure authentication:
Modify .env as needed
-
Start the server:
npm start
-
Test the API: Visit
http://localhost:3000in your browser or use curl:curl http://localhost:3000/
The server implements the following STAC API endpoints:
GET /- Root catalog with API informationGET /conformance- API conformance classesGET /collections- List of available collectionsGET /collections/{itemID}- Specific collection details
Configure authentication by setting the AUTH_METHOD environment variable:
AUTH_METHOD=basic
BASIC_AUTH_USERNAME=testuser
BASIC_AUTH_PASSWORD=testpassUsage:
curl -u testuser:testpass http://localhost:3000/collectionsSTAC Browser configuration for authConfig:
{
type: 'http',
scheme: 'basic'
}AUTH_METHOD=apikey
API_KEY=test-api-key-12345Usage with header:
curl -H "x-api-key: test-api-key-12345" http://localhost:3000/collectionsUsage with query parameter:
curl "http://localhost:3000/collections?api_key=test-api-key-12345"STAC Browser configuration for authConfig:
{
type: 'apiKey',
in: 'query',
name: 'api_key'
}AUTH_METHOD=noneAll configuration is handled via environment variables:
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3000 |
AUTH_METHOD |
Authentication method (basic, apikey, none) |
basic |
BASIC_AUTH_USERNAME |
Username for basic auth | testuser |
BASIC_AUTH_PASSWORD |
Password for basic auth | testpass |
API_KEY |
API key for key-based auth | test-api-key-12345 |