Usage
Standalone Usage
Using command line arguements:
chartx-server \
--port 3000 \
--origins http://localhost:3000 \
--dir ./data/charts \
--log-level info
Or using environment variables
PORT=3000
CORS_ORIGINS=http://localhost:3000
CHART_DIR=./data/charts
LOG_LEVEL=info
Using as an Express Module
chartx-server exports its core modules and routes, allowing it to be embedded into other Express applications.
import express from "express";
import * as chartx from "chartx-server";
chartx.logService.setLevel("info");
chartx.charter.loadCharts("./data/charts");
const app = express();
app.use(chartx.router);
app.listen(3000);
This enables custom authentication, extended routing, chart uploads, integration with existing APIs, and custom processing pipelines.
Assets Served
The server exposes HTTP endpoints for the following assets:
| Endpoint | Method | Description |
|---|---|---|
/ | GET | Gets chartx info with URLs of charts, glyphs and sprites. Used for loading all available ENCs in chartx web client automatically |
/charts | GET | Get chart details like name, DSID url, TileJSON url and vector tiles url. Used for loading ENCs manually in chartx web client |
/tiles/<CHART_NAME>/tiles.json | GET | Gets the TileJSON for loading vector tiles in Maplibre GL JS |
/tiles/<CHART_NAME>/{z}/{x}/{y}.pbf | GET | Gets vector tiles (.pbf) |
/sprites | GET | Gets the sprite ID and url for IHO presentation symbols |
/glyphs | GET | Gets the glyphs url and available fontstacks |
All assets are directly consumable by chartx web clients.
Configuration Options
| CLI Option | ENV | Description |
|---|---|---|
--port | PORT | HTTP server port |
--origins | CORS_ORIGINS | Allowed CORS origins |
--dir | CHART_DIR | Directory containing ENC charts and updates |
--log-level | LOG_LEVEL | Logging verbosity |
Configuration can be provided via CLI arguments or environment variables.
Startup Validation
On startup, the application performs the following checks:
- Verifies that GDAL is installed and supports S-57
- Verifies that Tippecanoe is available
- Scans the charts directory for ENC files and updates
- Generates a content hash for each chart
- Builds or reuses MBTiles based on detected changes
danger
If GDAL or Tippecanoe are not found, the server fails fast with a descriptive error.