contenttruck-js
v1.0.0
Published
The JS/TS SDK for Contenttruck.
Downloads
1
Readme
The JS/TS SDK for Contenttruck.
How to Use
To use this library, you will want to import the client:
import { Client } from 'contenttruck-js';
You can now go ahead and initialize it with the URL that points to the base path for your Contenttruck instance:
const client = new Client('https://cdn.webscalesoftware.ltd/');
Validation
All validators are exported from the package. These use zod and are internally inferred.
Options in Rule Set
When using createPartition
, you need to specify a rule set string that contains comma-separated options. Here are the possible options:
prefix
: specifies the path prefix that partitions will match.exact
: specifies the exact path that partitions will match.max-size
: specifies the maximum size of files that partitions will match.ensure
: specifies a validation string that partitions must satisfy. This will be passed to the validation engine which supports these options separated by plus signs:X:Y
: specifies this has to be a image with a aspect ratio of X:Y.jpeg
orjpg
: specifies this has to be a jpeg image.png
: specifies this has to be a png image.svg
: specifies this has to be a svg image.
- (invalid rule): any rule that is not one of the above options will result in an
ErrorCode.InvalidRuleset
being returned.