@@ -29,12 +29,11 @@ const client = new Kernel({
2929
3030async function main () {
3131 const response = await client .apps .deploy ({
32- appName: ' REPLACE_ME' ,
3332 file: fs .createReadStream (' path/to/file' ),
3433 version: ' REPLACE_ME' ,
3534 });
3635
37- console .log (response .id );
36+ console .log (response .apps );
3837}
3938
4039main ();
@@ -54,11 +53,7 @@ const client = new Kernel({
5453});
5554
5655async function main() {
57- const params: Kernel .AppDeployParams = {
58- appName: ' REPLACE_ME' ,
59- file: fs .createReadStream (' path/to/file' ),
60- version: ' REPLACE_ME' ,
61- };
56+ const params: Kernel .AppDeployParams = { file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' };
6257 const response: Kernel .AppDeployResponse = await client .apps .deploy (params );
6358}
6459
@@ -83,37 +78,17 @@ import Kernel, { toFile } from '@onkernel/sdk';
8378const client = new Kernel ();
8479
8580// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
86- await client .apps .deploy ({
87- appName: ' my-awesome-app' ,
88- file: fs .createReadStream (' /path/to/file' ),
89- version: ' 1.0.0' ,
90- });
81+ await client .apps .deploy ({ file: fs .createReadStream (' /path/to/file' ) });
9182
9283// Or if you have the web `File` API you can pass a `File` instance:
93- await client .apps .deploy ({
94- appName: ' my-awesome-app' ,
95- file: new File ([' my bytes' ], ' file' ),
96- version: ' 1.0.0' ,
97- });
84+ await client .apps .deploy ({ file: new File ([' my bytes' ], ' file' ) });
9885
9986// You can also pass a `fetch` `Response`:
100- await client .apps .deploy ({
101- appName: ' my-awesome-app' ,
102- file: await fetch (' https://somesite/file' ),
103- version: ' 1.0.0' ,
104- });
87+ await client .apps .deploy ({ file: await fetch (' https://somesite/file' ) });
10588
10689// Finally, if none of the above are convenient, you can use our `toFile` helper:
107- await client .apps .deploy ({
108- appName: ' my-awesome-app' ,
109- file: await toFile (Buffer .from (' my bytes' ), ' file' ),
110- version: ' 1.0.0' ,
111- });
112- await client .apps .deploy ({
113- appName: ' my-awesome-app' ,
114- file: await toFile (new Uint8Array ([0 , 1 , 2 ]), ' file' ),
115- version: ' 1.0.0' ,
116- });
90+ await client .apps .deploy ({ file: await toFile (Buffer .from (' my bytes' ), ' file' ) });
91+ await client .apps .deploy ({ file: await toFile (new Uint8Array ([0 , 1 , 2 ]), ' file' ) });
11792```
11893
11994## Handling errors
@@ -126,7 +101,7 @@ a subclass of `APIError` will be thrown:
126101``` ts
127102async function main() {
128103 const response = await client .apps
129- .deploy ({ appName: ' REPLACE_ME ' , file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' })
104+ .deploy ({ file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' })
130105 .catch (async (err ) => {
131106 if (err instanceof Kernel .APIError ) {
132107 console .log (err .status ); // 400
@@ -170,7 +145,7 @@ const client = new Kernel({
170145});
171146
172147// Or, configure per-request:
173- await client .apps .deploy ({ appName : ' REPLACE_ME ' , file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' }, {
148+ await client .apps .deploy ({ file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' }, {
174149 maxRetries: 5 ,
175150});
176151```
@@ -187,7 +162,7 @@ const client = new Kernel({
187162});
188163
189164// Override per-request:
190- await client .apps .deploy ({ appName: ' REPLACE_ME ' , file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' }, {
165+ await client .apps .deploy ({ file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' }, {
191166 timeout: 5 * 1000 ,
192167});
193168```
@@ -211,16 +186,16 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
211186const client = new Kernel ();
212187
213188const response = await client .apps
214- .deploy ({ appName: ' REPLACE_ME ' , file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' })
189+ .deploy ({ file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' })
215190 .asResponse ();
216191console .log (response .headers .get (' X-My-Header' ));
217192console .log (response .statusText ); // access the underlying Response object
218193
219194const { data : response, response : raw } = await client .apps
220- .deploy ({ appName: ' REPLACE_ME ' , file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' })
195+ .deploy ({ file: fs .createReadStream (' path/to/file' ), version: ' REPLACE_ME' })
221196 .withResponse ();
222197console .log (raw .headers .get (' X-My-Header' ));
223- console .log (response .id );
198+ console .log (response .apps );
224199```
225200
226201### Logging
0 commit comments