@cloudflare/sandbox 0.0.0-0ac3cfa → 0.0.0-18fac92
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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/client.ts +1 -1
- package/src/index.ts +22 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @cloudflare/sandbox
|
|
2
2
|
|
|
3
|
+
## 0.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#9](https://github.com/cloudflare/sandbox-sdk/pull/9) [`24f5470`](https://github.com/cloudflare/sandbox-sdk/commit/24f547048d5a26137de4656cea13d83ad2cc0b43) Thanks [@ItsWendell](https://github.com/ItsWendell)! - fix baseUrl for stub and stub forwarding
|
|
8
|
+
|
|
9
|
+
## 0.0.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#5](https://github.com/cloudflare/sandbox-sdk/pull/5) [`7c15b81`](https://github.com/cloudflare/sandbox-sdk/commit/7c15b817899e4d9e1f25747aaf439e5e9e880d15) Thanks [@ghostwriternr](https://github.com/ghostwriternr)! - Make package ready for deployment
|
|
14
|
+
|
|
3
15
|
## 0.0.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -212,7 +212,7 @@ export class HttpClient {
|
|
|
212
212
|
let response: Response;
|
|
213
213
|
|
|
214
214
|
if (this.options.stub) {
|
|
215
|
-
response = await this.options.stub.containerFetch(path, options, this.options.port);
|
|
215
|
+
response = await this.options.stub.containerFetch(this.baseUrl + path, options, this.options.port);
|
|
216
216
|
} else {
|
|
217
217
|
response = await fetch(this.baseUrl + path, options);
|
|
218
218
|
}
|
package/src/index.ts
CHANGED
|
@@ -8,24 +8,29 @@ export function getSandbox(ns: DurableObjectNamespace<Sandbox>, id: string) {
|
|
|
8
8
|
export class Sandbox<Env = unknown> extends Container<Env> {
|
|
9
9
|
defaultPort = 3000; // The default port for the container to listen on
|
|
10
10
|
sleepAfter = "3m"; // Sleep the sandbox if no requests are made in this timeframe
|
|
11
|
+
client: HttpClient;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
constructor(ctx: DurableObjectState, env: Env) {
|
|
14
|
+
super(ctx, env);
|
|
15
|
+
this.client = new HttpClient({
|
|
16
|
+
onCommandComplete: (success, exitCode, stdout, stderr, command, args) => {
|
|
17
|
+
console.log(
|
|
18
|
+
`[Container] Command completed: ${command}, Success: ${success}, Exit code: ${exitCode}`
|
|
19
|
+
);
|
|
20
|
+
},
|
|
21
|
+
onCommandStart: (command, args) => {
|
|
22
|
+
console.log(`[Container] Command started: ${command} ${args.join(" ")}`);
|
|
23
|
+
},
|
|
24
|
+
onError: (error, command, args) => {
|
|
25
|
+
console.error(`[Container] Command error: ${error}`);
|
|
26
|
+
},
|
|
27
|
+
onOutput: (stream, data, command) => {
|
|
28
|
+
console.log(`[Container] [${stream}] ${data}`);
|
|
29
|
+
},
|
|
30
|
+
port: this.defaultPort,
|
|
31
|
+
stub: this,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
29
34
|
|
|
30
35
|
envVars = {
|
|
31
36
|
MESSAGE: "I was passed in via the Sandbox class!",
|