-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85bc698
commit c8d384a
Showing
7 changed files
with
132 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
import { source, type S3Options } from '../core/source'; | ||
import { type Directory, PLUGIN_TYPE, type LoomSourceAdapter, LoomFile, MaybePromise } from '@loom-io/core'; | ||
|
||
export type S3MinioAdapterOptions = S3Options & { | ||
bucket: string; | ||
}; | ||
|
||
export default (key: string = 's3://', options: S3MinioAdapterOptions): LoomSourceAdapter => ({ | ||
export default (key: string = 's3://', bucket: string, s3config: S3Options): LoomSourceAdapter => ({ | ||
$type: PLUGIN_TYPE.SOURCE_ADAPTER, | ||
source: (link: string, Type?: typeof Directory | typeof LoomFile): MaybePromise<Directory | LoomFile> | void => { | ||
if(link.startsWith(key)) { | ||
const path = link.slice(key.length); | ||
const { bucket, ...s3options } = options; | ||
return source(path, bucket, s3options, Type); | ||
return source(path, bucket, s3config, Type); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
--- | ||
|
||
# In Memory Adapter | ||
|
||
This adapter was manly created for testing, but could also be used as a replacement for any other adapter. As the name told it stores all data in memory, which make it probably the fastest adapter. | ||
|
||
::: code-group | ||
|
||
```sh [npm] | ||
npm add @loom-io/in-memory-adapter | ||
``` | ||
|
||
```sh [pnpm] | ||
pnpm add @loom-io/in-memory-adapter | ||
``` | ||
|
||
```sh [bun] | ||
bun add @loom-io/in-memory-adapter | ||
``` | ||
|
||
::: | ||
|
||
## Setup and Config | ||
|
||
The adapter only has an default export and export a function to configure the adapter. In this case the only option is to set the key to reference it. As with all other adapters you can register it with different identifiers. The default identifier is `memory://`. | ||
|
||
```ts | ||
import Loom from "@loom-io/core"; | ||
import memoryAdapter from "@loom-io/in-memory-adapter"; | ||
|
||
Loom.register(memoryAdapter("my-memory://")); | ||
Loom.register(memoryAdapter()); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
--- | ||
|
||
# S3 Adapter | ||
|
||
Connects your S3 as it is a filesystem storage and based on the minio library. Even if it based on the minio library you can use it with all other S3 Storage e.g.: Digital Ocean Spaces, Amazon S3 | ||
|
||
::: code-group | ||
|
||
```sh [npm] | ||
npm add @loom-io/minio-s3-adapter | ||
``` | ||
|
||
```sh [pnpm] | ||
pnpm add @loom-io/minio-s3-adapter | ||
``` | ||
|
||
```sh [bun] | ||
bun add @loom-io/minio-s3-adapter | ||
``` | ||
|
||
::: | ||
|
||
## Setup and config | ||
|
||
Mainly the configuration is the same as with [minio](https://min.io/docs/minio/linux/developers/javascript/API.html). You just have setup a bucket name in advance. The default key to identify is `s3://` | ||
|
||
```ts | ||
import Loom from "@loom-io/core"; | ||
import s3Adapter from "@loom-io/s3-minio-adapter"; | ||
|
||
const s3ConfigMinio = { | ||
endPoint: "play.min.io", | ||
port: 9000, | ||
useSSL: true, | ||
accessKey: "Q3AM3UQ867SPQQA43P2F", | ||
secretKey: "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", | ||
}; | ||
|
||
const s3ConfigDigitalOcean = { | ||
endpoint: "ams3.digitaloceanspaces.com", | ||
accessKey: "key", | ||
secretKey: "secret", | ||
}; | ||
|
||
// Set own key, bucket name and config for minio | ||
Loom.register(memoryAdapter("my-s3://", "my-bucket", s3ConfigMinio)); | ||
// set default key (s3://), bucket name and digital ocean space config | ||
Loom.register(memoryAdapter(undefined, "other-bucket", s3ConfigDigitalOcean)); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
--- | ||
|
||
# Filesystem Adapter | ||
|
||
Access Files from you local filesystem. Don't be confused from the node in the package name, it should also work with bun, because it is node compatible, but there are plans to do a more Bun specific adapter. For now you should also use this for bun, because all adapter exchange able you can easily switch later to the Bun specific adapter if you want to. | ||
|
||
::: code-group | ||
|
||
```sh [npm] | ||
npm add @loom-io/node-filesystem-adapter | ||
``` | ||
|
||
```sh [pnpm] | ||
pnpm add @loom-io/node-filesystem-adapter | ||
``` | ||
|
||
```sh [bun] | ||
bun add @loom-io/node-filesystem-adapter | ||
``` | ||
|
||
::: | ||
|
||
## Setup and config | ||
|
||
The default key for this adapter is `file://`, by default the adapter sets your project directory as root directory (manly the directory you starts you server from), but you can set any other directory. This directory looks like and is accessed like you root directory, so you will not be able to break out of this directory. | ||
|
||
```ts | ||
import Loom from "@loom-io/core"; | ||
import filesystemAdapter from "@loom-io/node-filesystem-adapter"; | ||
|
||
// sets key to root:// and the root path to you filesystem root, be careful | ||
Loom.register(filesystemAdapter("root://", "/")); | ||
// use default config. Key is file:// and the "root"-Directory is your project root | ||
Loom.register(filesystemAdapter()); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters