src/extensions/default/StaticServer/node/StaticServerDomain.js
function init(domainManager) {
    _domainManager = domainManager;

    if (!domainManager.hasDomain("staticServer")) {
        domainManager.registerDomain("staticServer", {major: 0, minor: 1});
    }
    _domainManager.registerCommand(
        "staticServer",
        "_setRequestFilterTimeout",
        _cmdSetRequestFilterTimeout,
        false,
        "Unit tests only. Set timeout value for filtered requests.",
        [{
            name: "timeout",
            type: "number",
            description: "Duration to wait before passing a filtered request to the static file server."
        }],
        []
    );
    _domainManager.registerCommand(
        "staticServer",
        "getServer",
        _cmdGetServer,
        true,
        "Starts or returns an existing server for the given path.",
        [
            {
                name: "path",
                type: "string",
                description: "Absolute filesystem path for root of server."
            },
            {
                name: "port",
                type: "number",
                description: "Port number to use for HTTP server.  Pass zero to assign a random port."
            }
        ],
        [{
            name: "address",
            type: "{address: string, family: string, port: number}",
            description: "hostname (stored in 'address' parameter), port, and socket type (stored in 'family' parameter) for the server. Currently, 'family' will always be 'IPv4'."
        }]
    );
    _domainManager.registerCommand(
        "staticServer",
        "closeServer",
        _cmdCloseServer,
        false,
        "Closes the server for the given path.",
        [{
            name: "path",
            type: "string",
            description: "absolute filesystem path for root of server"
        }],
        [{
            name: "result",
            type: "boolean",
            description: "indicates whether a server was found for the specific path then closed"
        }]
    );
    _domainManager.registerCommand(
        "staticServer",
        "setRequestFilterPaths",
        _cmdSetRequestFilterPaths,
        false,
        "Defines a set of paths from a server's root path to watch and fire 'requestFilter' events for.",
        [
            {
                name: "root",
                type: "string",
                description: "absolute filesystem path for root of server"
            },
            {
                name: "paths",
                type: "Array",
                description: "path to notify"
            }
        ],
        []
    );
    _domainManager.registerCommand(
        "staticServer",
        "writeFilteredResponse",
        _cmdWriteFilteredResponse,
        false,
        "Overrides the server response from static middleware with the provided response data. This should be called only in response to a filtered request.",
        [
            {
                name: "root",
                type: "string",
                description: "absolute filesystem path for root of server"
            },
            {
                name: "path",
                type: "string",
                description: "path to rewrite"
            },
            {
                name: "resData",
                type: "{body: string, headers: Array}",
                description: "TODO"
            }
        ],
        []
    );
    _domainManager.registerEvent(
        "staticServer",
        "requestFilter",
        [{
            name: "location",
            type: "{hostname: string, pathname: string, port: number, root: string: id: number}",
            description: "request path"
        }]
    );
}
function init(domainManager) {
    _domainManager = domainManager;

    if (!domainManager.hasDomain("staticServer")) {
        domainManager.registerDomain("staticServer", {major: 0, minor: 1});
    }
    _domainManager.registerCommand(
        "staticServer",
        "_setRequestFilterTimeout",
        _cmdSetRequestFilterTimeout,
        false,
        "Unit tests only. Set timeout value for filtered requests.",
        [{
            name: "timeout",
            type: "number",
            description: "Duration to wait before passing a filtered request to the static file server."
        }],
        []
    );
    _domainManager.registerCommand(
        "staticServer",
        "getServer",
        _cmdGetServer,
        true,
        "Starts or returns an existing server for the given path.",
        [
            {
                name: "path",
                type: "string",
                description: "Absolute filesystem path for root of server."
            },
            {
                name: "port",
                type: "number",
                description: "Port number to use for HTTP server.  Pass zero to assign a random port."
            }
        ],
        [{
            name: "address",
            type: "{address: string, family: string, port: number}",
            description: "hostname (stored in 'address' parameter), port, and socket type (stored in 'family' parameter) for the server. Currently, 'family' will always be 'IPv4'."
        }]
    );
    _domainManager.registerCommand(
        "staticServer",
        "closeServer",
        _cmdCloseServer,
        false,
        "Closes the server for the given path.",
        [{
            name: "path",
            type: "string",
            description: "absolute filesystem path for root of server"
        }],
        [{
            name: "result",
            type: "boolean",
            description: "indicates whether a server was found for the specific path then closed"
        }]
    );
    _domainManager.registerCommand(
        "staticServer",
        "setRequestFilterPaths",
        _cmdSetRequestFilterPaths,
        false,
        "Defines a set of paths from a server's root path to watch and fire 'requestFilter' events for.",
        [
            {
                name: "root",
                type: "string",
                description: "absolute filesystem path for root of server"
            },
            {
                name: "paths",
                type: "Array",
                description: "path to notify"
            }
        ],
        []
    );
    _domainManager.registerCommand(
        "staticServer",
        "writeFilteredResponse",
        _cmdWriteFilteredResponse,
        false,
        "Overrides the server response from static middleware with the provided response data. This should be called only in response to a filtered request.",
        [
            {
                name: "root",
                type: "string",
                description: "absolute filesystem path for root of server"
            },
            {
                name: "path",
                type: "string",
                description: "path to rewrite"
            },
            {
                name: "resData",
                type: "{body: string, headers: Array}",
                description: "TODO"
            }
        ],
        []
    );
    _domainManager.registerEvent(
        "staticServer",
        "requestFilter",
        [{
            name: "location",
            type: "{hostname: string, pathname: string, port: number, root: string: id: number}",
            description: "request path"
        }]
    );
}
function init ( domainManager ) { _domainManager = domainManager ; if ( ! domainManager . hasDomain ( "staticServer" ) ) { domainManager . registerDomain ( "staticServer" , { major : 0 , minor : 1 } ) ; } _domainManager . registerCommand ( "staticServer" , "_setRequestFilterTimeout" , _cmdSetRequestFilterTimeout , false , "Unit tests only. Set timeout value for filtered requests." , [ { name : "timeout" , type : "number" , description : "Duration to wait before passing a filtered request to the static file server." } ] , [ ] ) ; _domainManager . registerCommand ( "staticServer" , "getServer" , _cmdGetServer , true , "Starts or returns an existing server for the given path." , [ { name : "path" , type : "string" , description : "Absolute filesystem path for root of server." } , { name : "port" , type : "number" , description : "Port number to use for HTTP server.  Pass zero to assign a random port." } ] , [ { name : "address" , type : "{address: string, family: string, port: number}" , description : "hostname (stored in 'address' parameter), port, and socket type (stored in 'family' parameter) for the server. Currently, 'family' will always be 'IPv4'." } ] ) ; _domainManager . registerCommand ( "staticServer" , "closeServer" , _cmdCloseServer , false , "Closes the server for the given path." , [ { name : "path" , type : "string" , description : "absolute filesystem path for root of server" } ] , [ { name : "result" , type : "boolean" , description : "indicates whether a server was found for the specific path then closed" } ] ) ; _domainManager . registerCommand ( "staticServer" , "setRequestFilterPaths" , _cmdSetRequestFilterPaths , false , "Defines a set of paths from a server's root path to watch and fire 'requestFilter' events for." , [ { name : "root" , type : "string" , description : "absolute filesystem path for root of server" } , { name : "paths" , type : "Array" , description : "path to notify" } ] , [ ] ) ; _domainManager . registerCommand ( "staticServer" , "writeFilteredResponse" , _cmdWriteFilteredResponse , false , "Overrides the server response from static middleware with the provided response data. This should be called only in response to a filtered request." , [ { name : "root" , type : "string" , description : "absolute filesystem path for root of server" } , { name : "path" , type : "string" , description : "path to rewrite" } , { name : "resData" , type : "{body: string, headers: Array}" , description : "TODO" } ] , [ ] ) ; _domainManager . registerEvent ( "staticServer" , "requestFilter" , [ { name : "location" , type : "{hostname: string, pathname: string, port: number, root: string: id: number}" , description : "request path" } ] ) ; }
Initializes the StaticServer domain with its commands.
@param {DomainManager} domainManager The DomainManager for the server
Initializes the StaticServer domain with its commands .