A Storage port adapter that can use S3 or MinIO for object storage in the hyper service framework
- Getting Started
- Usage with AWS S3
- Multiple Buckets or Namespaced Single Bucket
- Features
- Methods
- Testing
- License
hyper.config.js
import { default as minio } from 'https://raw.githubusercontent.com/hyper63/hyper-adapter-minio/main/mod.js'
export default {
app,
adapter: [
{
port: 'storage',
plugins: [
minio({ url: 'https://minioadmin:[email protected]', bucketPrefix: 'uniquePrefix' }),
],
},
],
}When you configure the hyper service with this adapter, you must provide a unique bucket prefix. This helps ensure your bucket name is globally unique
The unique name is an alphanumeric string that contains identifing information, this will enable you to identify the buckets created by this adapter.
There are two credentials needed in order for this adapter to interact with the underlying S3 or
MinIO resource: an accessKey and a secretKey. These credentials can be provided to this adapter
in a couple ways.
The first is simply in the url as the username and password:
minio({ url: 'https://accessKey:[email protected]', bucketPrefix: 'uniquePrefix' })You can also set the environment variables MINIO_ROOT_USER to your accessKey and
MINIO_ROOT_PASSWORD to your secretKey.
Credentials provided in the
urlwill supercede any credentials pulled from environment variables. In other words, if credentials are provided in both ways, the credentials derived from the url will be used.
This adapter can also be used on top on AWS' popular S3 service. To do so, simply adjust the host
in the url provided to the adapter to point to s3:
minio({
url: 'https://accessKey:[email protected]',
region: 'us-east-2',
bucketPrefix: 'uniquePrefix',
})
regiondefaults tous-east-1
This adapter can be configured to either create a bucket, in the underying S3 or MinIO, per hyper Storage Service, or instead to use a single namespaced bucket to store all objects across all hyper Storage services. In the latter configuration, each hyper Storage service is represented as a prefix in the single namespaced bucket.
Among other reasons, using a single namespaced bucket is a great option, if you're concerned with surpassing AWS' S3 Bucket Count Restriction
By default, the adapter uses the bucket per hyper Storage Service implementation. To enable the
single namespaced bucket approach, pass the useNamespacedBucket flag into the adapter:
minio({
url: 'https://accessKey:[email protected]',
bucketPrefix: 'uniquePrefix',
useNamespacedBucket: true,
})This will make the adapter create only a single bucket called uniquePrefix-namespaced. Each hyper
Storage Service is then implemented as a private prefix within the bucket. For example, if you had
hyper Storage services foo and bar, the structure of the bucket would look like:
- uniquePrefix-namespaced
--|/foo
---| foo.png
---| .... # all objects in the 'foo' Storage Service here
--| /bar
---| bar.png
---| .... # all objects in the 'bar' Storage Service here
- Create an
s3compatible bucket - Remove an
s3compatible bucket - List
s3compatible buckets - Put an object into an
s3compatible bucket - Remove an object from an
s3compatible bucket - Get an object from an
s3compatible bucket - List objects in an
s3compatible bucket
This adapter fully implements the Storage port and can be used as the hyper Storage service adapter
See the full port here
deno task test
To lint, check formatting, and run unit tests
To run the test harness, run deno task test:harness. a hyper server with the adapter installed
will be running on port 6363
Apache-2.0