Examples
The repository ships with runnable end-to-end examples in examples/. Each one is self-contained, typed, and safe to copy/paste as a starting point.
Connecting
Section titled “Connecting”| File | What it shows |
|---|---|
sftp-basic.ts | Password-auth SFTP, list + download. |
sftp-private-key.ts | Public-key SFTP with known_hosts and host-key pinning. |
ssh-exec-command.ts | Standalone SSH transport: handshake, auth, exec, drain stdout. |
ftp-basic.ts | Plain FTP with passive mode. |
ftps-basic.ts | Explicit FTPS with a CA bundle. |
ftps-client-certificate.ts | FTPS with mTLS + fingerprint pinning. |
profile-from-env.ts | Build a ConnectionProfile entirely from env vars. |
diagnose-connection.ts | Run connection diagnostics with redacted output. |
Directory operations
Section titled “Directory operations”The provider-neutral session.fs surface (list, stat, mkdir, rename, remove, rmdir) is identical across protocols - these three show the same flow on each classic backend.
| File | What it shows |
|---|---|
ftp-directory-ops.ts | Classic FTP commands (MLSD, MLST, RNFR/RNTO, …) as typed methods. |
ftps-directory-ops.ts | Same surface over encrypted control + data channels. |
sftp-directory-ops.ts | Same surface backed by SSH file-attribute packets. |
Cloud providers
Section titled “Cloud providers”| File | What it shows |
|---|---|
s3-compatible-upload.ts | Parallel multipart upload to S3 (and any S3-compatible bucket) with resumable checkpoints. |
signed-url-download.ts | Resolve an HTTP signed URL and stream it to disk. |
webdav-sync.ts | One-way sync to a WebDAV server, with delete-policy. |
multi-cloud-orchestration.ts | Pull from S3, push to Azure Blob + GCS in parallel. |
Transfers, sync, MFT
Section titled “Transfers, sync, MFT”| File | What it shows |
|---|---|
local-copy-file.ts | Copy a file using the local filesystem provider. |
transfer-queue.ts | Bounded-concurrency queue with progress + retry. |
retry-and-timeouts.ts | Retry policy, two-scope timeouts, stall watchdog, client-wide defaults - runs fully offline. |
resume-checkpoints.ts | Checkpoint store + retry resuming a dropped transfer from the byte watermark - runs fully offline. |
resumable-batch.ts | Crash-safe batch plan: completed steps skip on re-run, only failed work re-executes - runs fully offline. |
dry-run-sync.ts | Plan a sync, summarise it, decide whether to execute. |
atomic-deploy-with-rollback.ts | Stage → swap → rollback pattern for zero-downtime releases. |
mft-route.ts | Define a route + schedule + scheduler. |
approval-gated-route.ts | Wrap a route in a human-approval gate before bytes move. |
Running an example
Section titled “Running an example”# from repo rootnpm installnpm run build
# run with tsx (already a devDep)npx tsx examples/sftp-private-key.tsMost examples read connection details from environment variables - see the top of each file for the expected names. Use examples/profile-from-env.ts as a template for your own integrations.