@zimic/interceptor 0.19.1-canary.4 → 0.19.1-canary.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,14 @@
1
- /**
2
- * The options to create an {@link https://zimic.dev/docs/interceptor/cli/server interceptor server}.
3
- *
4
- * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
5
- */
1
+ /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
6
2
  export interface InterceptorServerOptions {
7
- /**
8
- * The hostname to start the server on.
9
- *
10
- * @default localhost
11
- */
3
+ /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
12
4
  hostname?: string;
13
5
 
14
- /** The port to start the server on. If no port is provided, a random one is chosen. */
6
+ /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
15
7
  port?: number;
16
8
 
17
- /**
18
- * Whether to log warnings about unhandled requests to the console.
19
- *
20
- * @default true
21
- */
9
+ /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
22
10
  logUnhandledRequests?: boolean;
23
11
 
24
- /**
25
- * The directory where the authorized interceptor authentication tokens are saved. If provided, only remote
26
- * interceptors bearing a valid token will be accepted. This option is essential if you are exposing your interceptor
27
- * server publicly. For local development and testing, though, `--tokens-dir` is optional.
28
- *
29
- * @default undefined
30
- */
12
+ /** @see {@link https://zimic.dev/docs/interceptor/api/create-interceptor-server `createInterceptorServer` API reference} */
31
13
  tokensDirectory?: string;
32
14
  }
@@ -1,65 +1,26 @@
1
- /**
2
- * A server to intercept and handle requests. It is used in combination with
3
- * {@link https://zimic.dev/docs/interceptor/guides/http/remote-interceptors remote interceptors}.
4
- *
5
- * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
6
- */
1
+ /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
7
2
  export interface InterceptorServer {
8
- /**
9
- * The hostname of the server. It can be reassigned to a new value if the server is not running.
10
- *
11
- * @throws {RunningInterceptorServerError} When trying to reassign a new hostname with the server still running.
12
- * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
13
- */
3
+ /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
14
4
  hostname: string;
15
5
 
16
- /**
17
- * The port of the server. It can be reassigned to a new value if the server is not running.
18
- *
19
- * @throws {RunningInterceptorServerError} When trying to reassign a new port with the server still running.
20
- * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
21
- */
6
+ /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
22
7
  port: number | undefined;
23
8
 
24
- /**
25
- * Whether to log warnings about unhandled requests to the console.
26
- *
27
- * @default true
28
- * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
29
- */
9
+ /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
30
10
  logUnhandledRequests: boolean;
31
11
 
32
- /**
33
- * The directory where the authorized interceptor authentication tokens are saved. If provided, only remote
34
- * interceptors bearing a valid token will be accepted. This option is essential if you are exposing your interceptor
35
- * server publicly. For local development and testing, though, `--tokens-dir` is optional.
36
- *
37
- * @default undefined
38
- */
12
+ /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
39
13
  tokensDirectory?: string;
40
14
 
41
15
  /**
42
- * Whether the server is running.
43
- *
44
16
  * @readonly
45
- * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
17
+ * @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference}
46
18
  */
47
19
  get isRunning(): boolean;
48
20
 
49
- /**
50
- * Starts the server.
51
- *
52
- * The server is automatically stopped if a process exit event is detected, such as SIGINT, SIGTERM, or an uncaught
53
- * exception.
54
- *
55
- * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
56
- */
21
+ /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
57
22
  start: () => Promise<void>;
58
23
 
59
- /**
60
- * Stops the server.
61
- *
62
- * @see {@link https://zimic.dev/docs/interceptor/cli/server `zimic-interceptor server` API reference}
63
- */
24
+ /** @see {@link https://zimic.dev/docs/interceptor/api/interceptor-server `InterceptorServer` API reference} */
64
25
  stop: () => Promise<void>;
65
26
  }
@@ -69,11 +69,11 @@ export class CommandError extends Error {
69
69
  }
70
70
  }
71
71
 
72
- export async function runCommand(command: string, commandArguments: string[]) {
72
+ export async function runCommand(commandEntry: string, commandArguments: string[]) {
73
73
  const { execa: $, ExecaError } = await importExeca();
74
74
 
75
75
  try {
76
- await $(command, commandArguments, { stdio: 'inherit' });
76
+ await $(commandEntry, commandArguments, { stdio: 'inherit' });
77
77
  } catch (error) {
78
78
  /* istanbul ignore if -- @preserve
79
79
  * This is a safeguard if the error is not an ExecaError. It is not expected to run. */
@@ -81,8 +81,8 @@ export async function runCommand(command: string, commandArguments: string[]) {
81
81
  throw error;
82
82
  }
83
83
 
84
- const commandError = new CommandError(command, {
85
- command: [command, ...commandArguments],
84
+ const commandError = new CommandError(commandEntry, {
85
+ command: [commandEntry, ...commandArguments],
86
86
  exitCode: error.exitCode,
87
87
  signal: error.signal,
88
88
  originalMessage: error.originalMessage,