@travetto/asset
Advanced tools
Comparing version 0.3.19 to 0.3.20
@@ -10,6 +10,6 @@ { | ||
"dependencies": { | ||
"@travetto/cache": "^0.3.18", | ||
"@travetto/di": "^0.3.20", | ||
"@travetto/exec": "^0.3.15", | ||
"@travetto/util": "^0.3.13", | ||
"@travetto/cache": "^0.3.19", | ||
"@travetto/di": "^0.3.21", | ||
"@travetto/exec": "^0.3.16", | ||
"@travetto/net": "^0.3.14", | ||
"@types/file-type": "^5.2.1", | ||
@@ -23,3 +23,3 @@ "@types/mime": "^2.0.0", | ||
"devDependencies": { | ||
"@travetto/test": "^0.3.19" | ||
"@travetto/test": "^0.3.20" | ||
}, | ||
@@ -42,4 +42,4 @@ "homepage": "https://travetto.io", | ||
}, | ||
"version": "0.3.19", | ||
"gitHead": "4cb5df8e6251cd6f887cc4d964565f5c0451e4f0" | ||
"version": "0.3.20", | ||
"gitHead": "e38c3aadc9bb556c795aabbfc1f0021079f42631" | ||
} |
@@ -6,18 +6,10 @@ travetto: Asset | ||
[`GraphicsMagick`](http://www.graphicsmagick.org) is used under the covers for image transformation. If the binary is not installed the framework will spin up a [`docker`](https://www.docker.com/community-edition) container to provide needed functionality. | ||
The asset module requires an [`AssetSource`](./src/service/source.ts) to provide functionality for reading and writing files. The `AssetSource` will need to be configured to be picked up by the `AssetService` | ||
The primary driver for the Asset framework is an [`AssetSource`](./src/service/source.ts) which needs to be implemented to provide code on how to read and write files. | ||
Initially you need to configure the [`AssetSource`](./src/service/source.ts) to provide a backend for the storage and retrieval. Below we are using the [`Asset-Mongo`](https://github.com/travetto/travetto/tree/master/module/asset-mongo) as the backend, but there are others to choose from. | ||
```typescript | ||
class AppConfig { | ||
@InjectableFactory() | ||
static getConf(): AssetMongoConfig { | ||
return new AssetMongoConfig(); | ||
static getSource(): AssetSource { | ||
return new CustomAssetSource(); | ||
} | ||
@InjectableFactory() | ||
static getSource(cfg: AssetMongoConfig): AssetSource { | ||
return new AssetMongoSource(cfg); | ||
} | ||
} | ||
@@ -27,4 +19,7 @@ ``` | ||
After that, both [`AssetService`](./src/service/asset.ts) and [`ImageService`](./src/service/image.ts) will rely upon the [`AssetSource`](./src/service/source.ts) to do their work. Below you can see an example of storing and retrieving a user's profile image. | ||
Storing of all assets goes through the [`AssetService`](./src/service/asset.ts), but retrieval can either be from [`AssetService`](./src/service/asset.ts) or [`ImageService`](./src/service/image.ts) depending on whether or not you want to perform image optimizations on retrieval. | ||
## Images | ||
Storing of all assets uses the [`AssetService`](./src/service/asset.ts), but retrieval can either be from [`AssetService`](./src/service/asset.ts) or [`ImageService`](./src/service/image.ts) depending on whether or not you want to perform image optimizations on retrieval. The `ImageService` users [`GraphicsMagick`](http://www.graphicsmagick.org) for image transformation. If the binary is not installed the framework will spin up a [`docker`](https://www.docker.com/community-edition) container to provide needed functionality. | ||
```typescript | ||
@@ -54,7 +49,2 @@ @Injectable() | ||
The current set of supported [`AssetSource`](./src/service/source.ts) implementations are: | ||
- [`Asset-Mongo`](https://github.com/travetto/travetto/tree/master/module/asset-mongo#readme) provides the mongodb driver for file management | ||
- [`Asset-S3`](https://github.com/travetto/travetto/tree/master/module/asset-s3#readme) provides the S3 driver for file management | ||
Additionally, the `ImageService` currently supports the ability to resize an image on the fly, while auto orienting. |
@@ -9,3 +9,3 @@ import * as fs from 'fs'; | ||
import { HttpRequest } from '@travetto/util'; | ||
import { HttpRequest } from '@travetto/net'; | ||
import { Asset, AssetFile } from './model'; | ||
@@ -116,3 +116,3 @@ | ||
} else { | ||
newFilePath += `.${responseExt}`; | ||
newFilePath = `${newFilePath}.${responseExt}`; | ||
} | ||
@@ -119,0 +119,0 @@ await fsRenameAsync(filePath, newFilePath); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18534
12
48
1
+ Added@travetto/net@^0.3.14
+ Added@travetto/net@0.3.14(transitive)
- Removed@travetto/util@^0.3.13
- Removed@travetto/util@0.3.13(transitive)
Updated@travetto/cache@^0.3.19
Updated@travetto/di@^0.3.21
Updated@travetto/exec@^0.3.16