Skip to content

Commit

Permalink
export some types that might be useful from index
Browse files Browse the repository at this point in the history
  • Loading branch information
sepbot committed Nov 5, 2024
1 parent 470a453 commit faf6a98
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
# docker-client-ts

installation
## installation
```shell
npm add docker-client-ts
```

see [tests](tests) for example usage
## usage
```typescript
import { DockerClient } from "docker-client-ts";

const docker = await DockerClient({
baseURL: new URL("unix:/var/run/docker.sock"),
ssh: {
user: "username",
host: "127.0.0.1",
port: 22,
key: Buffer.from("ssh private key", "utf8"),
},
});

const { Id } = await client.Container.Create({
body: {
Image: "debian",
Cmd: ["bash"],
Tty: true,
},
});

await client.Container.Start({
path: { id: Id },
});
```

see [tests](tests) for more example usage

<sub>
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States
and/or other countries. Docker, Inc. and other parties may also have trademark rights in other terms used herein.
</sub>
5 changes: 4 additions & 1 deletion static/etc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export function terminal(resp: Dispatcher.UpgradeData): TerminalSession {
};

resp.socket.on("data", (chunk: Buffer) => {
output.next(chunk.subarray(8).toString("binary"));
const out = chunk.subarray(8).toString("binary");
for (const line of out.trim().split("\n")) {
output.next(line);
}
});

setTimeout(async () => {
Expand Down
3 changes: 3 additions & 0 deletions templates/root.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {{ tag }} from "~/tags/{{ tag | lower }}"
{% endfor %}

export { ComposeSpecificationSchema } from "~/compose";
export { type DockerClientParams } from "~/etc"

export type DockerClientType = Awaited<ReturnType<typeof DockerClient>>;

export async function DockerClient(params: DockerClientParams) {
const { pool, close } = await getPool(params);
Expand Down

0 comments on commit faf6a98

Please sign in to comment.