Skip to navigation

addDirectory

View as MarkdownOpen in Claude

Add a directory to serve at a URL route prefix. You can call it before or after the service starts; the route serves from the next request.

Parameters

route
stringRequired

URL prefix, for example '/docs'. A leading / is added if missing.

directory
stringRequired

Local directory path to serve.

Returns

void

Throws an Error if the directory does not exist or the path is not a directory.

Example

import { WebService } from '@signalwire/sdk';
const web = new WebService({
basicAuth: ['assets', process.env['ASSETS_PASSWORD'] ?? ''],
});
web.addDirectory('/images', './public/images');
await web.start();