Skip to content

Commit 5c5e92b

Browse files
committed
docs: update documentation
1 parent d97127a commit 5c5e92b

File tree

2 files changed

+62
-2
lines changed
  • docs/storage-image-processing-api
  • extensions/storage-image-processing-api/lib

2 files changed

+62
-2
lines changed

docs/storage-image-processing-api/index.mdx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,40 @@ const operations = [
129129
const encodedOperations = encodeURIComponent(JSON.stringify(operations));
130130
const url = `https://{LOCATION}-{PROJECT_ID}.cloudfunctions.net/ext-storage-image-processing-api-handler/process?operations=${encodedOperations}`;
131131
```
132+
133+
### JavaScript utility library
134+
135+
Additionally, a utility library exists to provide a fully typed interface for constructing options.
136+
137+
Firstly, install the [library](https://www.npmjs.com/package/@invertase/storage-image-processing-api) via npm:
138+
139+
```bash
140+
npm i --save @invertase/storage-image-processing-api
141+
```
142+
143+
Use the `builder` function to return a `StorageImageProcessingApi` instance which can be used to build an array of operations:
144+
145+
```ts
146+
import { builder } from '@invertase/storage-image-processing-api';
147+
148+
const output = builder()
149+
// Input required
150+
.input({
151+
source: 'https://example.com/image.jpg',
152+
})
153+
.flip()
154+
.grayscale()
155+
.rotate({ angle: 90 })
156+
// Output required
157+
.output({
158+
format: 'png',
159+
});
160+
```
161+
162+
Once created, the api provides the means to return the operations as JSON, a JSON string or an encoded JSON string suitable for GET requests in your browser.
163+
164+
```ts
165+
const json = output.toJSON();
166+
const jsonString = output.toJSONString();
167+
const encodedJsonString = output.toEncodedJSONString();
168+
```

extensions/storage-image-processing-api/lib/README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Storage Image Processing API Utilities
22

3-
This package contains utilities for interacting with the [Firebase Storage Image Processing API Extension](#todo).
3+
This package contains utilities for interacting with the Firebase Storage Image Processing API Extension.
44

55
## Installation
66

@@ -14,4 +14,27 @@ npm i --save @invertase/storage-image-processing-api
1414

1515
Returns a `StorageImageProcessingApi` instance which can be used to build an array of operations to be applied to an image via the extension.
1616

17-
Once built,
17+
```ts
18+
import { builder } from '@invertase/storage-image-processing-api';
19+
20+
const output = builder()
21+
// Input required
22+
.input({
23+
source: 'https://example.com/image.jpg',
24+
})
25+
.flip()
26+
.grayscale()
27+
.rotate({ angle: 90 })
28+
// Output required
29+
.output({
30+
format: 'png',
31+
});
32+
```
33+
34+
Once created, the api provides the means to return the operations as JSON, a JSON string or an encoded JSON string suitable for GET requests in your browser.
35+
36+
```ts
37+
const json = output.toJSON();
38+
const jsonString = output.toJSONString();
39+
const encodedJsonString = output.toEncodedJSONString();
40+
```

0 commit comments

Comments
 (0)