http-simple-serve (main) doxdox documentation

Simple HTTP server for use with static resources.

# readStaticAssetsSync(root, entry)

Returns a list of file paths and their content types found recursively in a given path.

Parameters

Name Types Description
root String Relative path to the root of a given directory.
entry String The default resource to return when accessing the root of the main directory.

Returns

{[key: string]: { path: string; contentType: string; }}

The list of file paths and content types.

# server(options, options.port, options.root, options.entry)

Generates an HTTP server for serving up static resources.

Parameters

Name Types Description
options Object
options.port Number Port to run HTTP server from.
options.root String Relative path to the root of a given directory.
options.entry String The default resource to return when accessing the root of the main directory.

Returns

Server<typeof IncomingMessage, typeof ServerResponse>

HTTP server.

# tryGetContentType(path)

Returns the content type of a file for use in an HTTP response header.

Parameters

Name Types Description
path String A relative file path.

Returns

String

The content type for the given file path.

# tryParseUrl(url)

Returns a parsed URL. If the URL is to a directory, the trailing slash is removed.

Parameters

Name Types Description
url String The requested URL.

Returns

String

The parsed URL.