Skip to content

Commit

Permalink
feat: allow to add static content
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKreil committed Feb 3, 2024
1 parent 8e543bc commit 9bf3dfb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ program
.option('-h, --host <hostnameip>', 'Hostname or IP to bind the server to', '0.0.0.0')
.option('-o, --open', 'Open map in web browser')
.option('-p, --port <port>', 'Port to bind the server to (default: 8080)')
.option('-s, --static <folder>', 'Path to a folder with static files')
.option('-t, --tms', 'Use TMS tile order (flip y axis)')
.argument('<source>', 'VersaTiles container, can be a URL or filename of a "*.versatiles" file')
.action(async (source: string, cmdOptions: Record<string, unknown>) => {
Expand All @@ -29,6 +30,7 @@ program
compress: Boolean(cmdOptions.compress),
host: String(cmdOptions.host ?? '0.0.0.0'),
port: Number(cmdOptions.port ?? 8080),
static: cmdOptions.static as string | undefined,
tms: Boolean(cmdOptions.tms),
};

Expand Down
4 changes: 4 additions & 0 deletions src/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ export class Server {

staticContent.addFolder('/assets', resolvePath(DIRNAME, 'static/assets'));

if (this.#options.static != null) {
staticContent.addFolder('/', this.#options.static);
}

return staticContent;
}
}
1 change: 1 addition & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface ServerOptions {
tilesUrl?: string;
host?: string;
port?: number;
static?: string;
tms?: boolean;
}

Expand Down

0 comments on commit 9bf3dfb

Please sign in to comment.