@yopdev/dev-server 2.0.4 → 3.0.0
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.
package/dist/src/dev-server.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { Config } from "./config";
|
|
2
|
-
import {
|
|
3
|
-
export declare class DevServer
|
|
2
|
+
import { Service } from "./services";
|
|
3
|
+
export declare class DevServer {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
private readonly service;
|
|
6
6
|
private readonly config?;
|
|
7
7
|
private readonly eventProxyTopic;
|
|
8
8
|
private LOGGER;
|
|
9
9
|
private localStack;
|
|
10
|
+
private network;
|
|
10
11
|
constructor(name: string, service: Service<any>, config?: Config);
|
|
11
|
-
start: () => Promise<
|
|
12
|
-
stop: () => Promise<void>;
|
|
12
|
+
start: () => Promise<StartedDevServer>;
|
|
13
13
|
private shutdown;
|
|
14
14
|
}
|
|
15
|
+
type StartedDevServer = {
|
|
16
|
+
name: string;
|
|
17
|
+
stop: () => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
package/dist/src/dev-server.js
CHANGED
|
@@ -14,7 +14,8 @@ class DevServer {
|
|
|
14
14
|
this.name = name;
|
|
15
15
|
this.service = service;
|
|
16
16
|
this.config = config;
|
|
17
|
-
this.start = () => Promise.resolve(new testcontainers_1.Network(new testcontainers_1.RandomUuid()).start())
|
|
17
|
+
this.start = async () => Promise.resolve(new testcontainers_1.Network(new testcontainers_1.RandomUuid()).start())
|
|
18
|
+
.tap((network) => this.network = network)
|
|
18
19
|
.then((network) => ({
|
|
19
20
|
localStack: this.localStack = new localstack_1.LocalStack(network, this.config),
|
|
20
21
|
network: network
|
|
@@ -46,12 +47,14 @@ class DevServer {
|
|
|
46
47
|
.then(() => this.LOGGER.error('error starting service'))
|
|
47
48
|
.then(() => Promise.reject(e)))
|
|
48
49
|
.then(() => this.LOGGER.info('started'))
|
|
49
|
-
.then(() =>
|
|
50
|
-
|
|
51
|
-
.then(() => this.LOGGER.info('stopped'))
|
|
50
|
+
.then(() => ({
|
|
51
|
+
name: this.name,
|
|
52
|
+
stop: async () => this.shutdown().then(() => this.LOGGER.info('stopped')),
|
|
53
|
+
}));
|
|
52
54
|
this.shutdown = async () => this.service.stop()
|
|
53
|
-
.
|
|
54
|
-
.then(() => this.localStack?.stop())
|
|
55
|
+
.finally(tunnel_1.terminate)
|
|
56
|
+
.then(() => this.localStack?.stop())
|
|
57
|
+
.then(() => this.network?.stop().catch((e) => this.LOGGER.warn(e, 'failed to stop network')));
|
|
55
58
|
this.LOGGER = logging_1.LoggerFactory.create(`DEVSERVER[${name}]`);
|
|
56
59
|
const encodedName = Buffer.from(name).toString('hex').substring(0, 64);
|
|
57
60
|
this.eventProxyTopic = `EventProxyTopic${encodedName}`;
|