Skip to main content

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:

EndpointMethodDescription
/GETGets chartx info with URLs of charts, glyphs and sprites. Used for loading all available ENCs in chartx web client automatically
/chartsGETGet 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.jsonGETGets the TileJSON for loading vector tiles in Maplibre GL JS
/tiles/<CHART_NAME>/{z}/{x}/{y}.pbfGETGets vector tiles (.pbf)
/spritesGETGets the sprite ID and url for IHO presentation symbols
/glyphsGETGets the glyphs url and available fontstacks

All assets are directly consumable by chartx web clients.

Configuration Options

CLI OptionENVDescription
--portPORTHTTP server port
--originsCORS_ORIGINSAllowed CORS origins
--dirCHART_DIRDirectory containing ENC charts and updates
--log-levelLOG_LEVELLogging verbosity

Configuration can be provided via CLI arguments or environment variables.

Startup Validation

On startup, the application performs the following checks:

  1. Verifies that GDAL is installed and supports S-57
  2. Verifies that Tippecanoe is available
  3. Scans the charts directory for ENC files and updates
  4. Generates a content hash for each chart
  5. Builds or reuses MBTiles based on detected changes
danger

If GDAL or Tippecanoe are not found, the server fails fast with a descriptive error.