• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

microsoft / botbuilder-js / 4872067562

pending completion
4872067562

Pull #4471

github

GitHub
Merge dbfd4c509 into 25e71468a
Pull Request #4471: fix: [#4466] Fix telemetry activityId and conversationId properties

9688 of 12724 branches covered (76.14%)

Branch coverage included in aggregate %.

8 of 8 new or added lines in 3 files covered. (100.0%)

19962 of 22417 relevant lines covered (89.05%)

3342.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.57
/libraries/botframework-streaming/src/utilities/createNodeServer.ts
1
/**
2
 * @module botframework-streaming
3
 */
4
/**
5
 * Copyright (c) Microsoft Corporation. All rights reserved.
6
 * Licensed under the MIT License.
7
 */
8

9
import { INodeServer, INodeSocket } from '../interfaces';
10

11
type ConnectionListener = (socket: INodeSocket) => void;
12

13
/**
14
 * Create a Node 'net' server
15
 *
16
 * @param callback Optional connection listener
17
 * @returns a Node 'net' server instance
18
 */
19
export function createNodeServer(callback?: ConnectionListener): INodeServer {
1✔
20
    if (callback && typeof callback !== 'function') {
1!
21
        throw new TypeError("Invalid callback; callback parameter must be a function to create Node 'net' Server.");
×
22
    }
23

24
    const server = getServerFactory()(callback);
1✔
25
    if (!isNetServer(server)) {
1!
26
        throw new Error("Unable to create Node 'net' server");
×
27
    }
28

29
    return server;
1✔
30
}
31

32
/**
33
 * Get a function that creates a Node 'net' server instance
34
 *
35
 * @returns a server factory function
36
 */
37
export function getServerFactory(): (callback?: ConnectionListener) => INodeServer {
1✔
38
    if (typeof require !== undefined) {
1!
39
        // eslint-disable-next-line @typescript-eslint/no-var-requires
40
        return require('net').Server;
1✔
41
    }
42

43
    throw TypeError(
×
44
        "require is undefined. Must be in a Node module to require 'net' dynamically in order to fetch Server factory."
45
    );
46
}
47

48
// eslint-disable-next-line @typescript-eslint/no-explicit-any
49
function isNetServer(o: any): o is INodeServer {
50
    return hasCloseMethod(o) && hasListenMethod(o);
1✔
51
}
52

53
// eslint-disable-next-line @typescript-eslint/no-explicit-any
54
function hasCloseMethod(o: any): o is INodeServer {
55
    return o.close && typeof o.close === 'function';
1✔
56
}
57

58
// eslint-disable-next-line @typescript-eslint/no-explicit-any
59
function hasListenMethod(o: any): o is INodeServer {
60
    return o.listen && typeof o.listen === 'function';
1✔
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc