Skip to content

Commit 819c151

Browse files
committed
docs: update docs
1 parent 24b1e16 commit 819c151

File tree

2 files changed

+71
-20
lines changed

2 files changed

+71
-20
lines changed

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

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,37 +132,21 @@ const url = `https://{LOCATION}-{PROJECT_ID}.cloudfunctions.net/ext-storage-imag
132132

133133
### JavaScript utility library
134134

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:
135+
Additionally, a utility library exists to provide a fully typed interface for constructing options:
144136

145137
```ts
146138
import { builder } from '@invertase/storage-image-processing-api';
147139

148140
const output = builder()
149-
// Input required
150141
.input({
151142
source: 'https://example.com/image.jpg',
152143
})
153-
.flip()
154-
.grayscale()
155144
.rotate({ angle: 90 })
156-
// Output required
157145
.output({
158146
format: 'png',
159147
});
160-
```
161148

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.
149+
console.log(output.toJSON());
150+
```
163151

164-
```ts
165-
const json = output.toJSON();
166-
const jsonString = output.toJSONString();
167-
const encodedJsonString = output.toEncodedJSONString();
168-
```
152+
For more details, [view the documentation](/utility-library).
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Utilty Library
2+
3+
To assist with the usage of this Extension, a [utility library](https://www.npmjs.com/package/@invertase/storage-image-processing-api) exists
4+
to help provide a typed API interface for easily constructing operations to send to the API.
5+
6+
## Installation
7+
8+
```bash
9+
npm i --save @invertase/storage-image-processing-api
10+
```
11+
12+
## Usage
13+
14+
Once installed, import the `builder` function from the library:
15+
16+
```ts
17+
import { builder } from '@invertase/storage-image-processing-api';
18+
```
19+
20+
The `builder` function returns a new `StorageImageProcessingApi` instance which provides a API for constructing operations to send to the API.
21+
At a minimum, you must provide an `input` and `output` operation as required by the extension itself:
22+
23+
```ts
24+
import { builder } from '@invertase/storage-image-processing-api';
25+
26+
const build = builder()
27+
.input({
28+
url: 'https://example.com/image.jpg',
29+
})
30+
.output({
31+
format: 'png',
32+
});
33+
```
34+
35+
To provide additional operations, you can chain them together. For example,
36+
to apply a blur, grayscale and flip the provided input image, and return a new PNG image:
37+
38+
```ts
39+
const output = builder()
40+
.input({
41+
url: 'https://example.com/image.jpg',
42+
})
43+
.blur()
44+
.grayscale()
45+
.flip()
46+
.output({
47+
format: 'png',
48+
});
49+
```
50+
51+
Please refer to the [operations](/operations) documentatuion for a full list of available operations, their API and examples.
52+
53+
Once you have constructed your operations, you can return the operations as JSON, a JSON string or encoded JSON string value:
54+
55+
```ts
56+
const json = output.toJSON();
57+
const jsonString = output.toJSONString();
58+
const encodedJsonString = output.toEncodedJSONString();
59+
```
60+
61+
The encoded JSON string value can be passed directly to the extension as the `operations` parameter:
62+
63+
```ts
64+
const encodedJsonString = output.toEncodedJSONString();
65+
66+
const url = `https://{LOCATION}-{PROJECT_ID}.cloudfunctions.net/ext-storage-image-processing-api-handler/process?operations=${encodedJsonString}`
67+
```

0 commit comments

Comments
 (0)