{"id":13651027,"url":"https://github.com/designtesbrot/moleculer-minio","last_synced_at":"2025-04-22T22:30:24.157Z","repository":{"id":52834740,"uuid":"161765618","full_name":"designtesbrot/moleculer-minio","owner":"designtesbrot","description":"💾A moleculer service mixin for minio and S3 💾","archived":false,"fork":false,"pushed_at":"2022-09-16T17:31:23.000Z","size":91,"stargazers_count":15,"open_issues_count":3,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T00:06:51.438Z","etag":null,"topics":["minio","moleculer","moleculerjs","s3-storage"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/designtesbrot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-14T09:57:03.000Z","updated_at":"2024-10-20T22:21:16.000Z","dependencies_parsed_at":"2022-09-09T12:41:41.069Z","dependency_job_id":null,"html_url":"https://github.com/designtesbrot/moleculer-minio","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designtesbrot%2Fmoleculer-minio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designtesbrot%2Fmoleculer-minio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designtesbrot%2Fmoleculer-minio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designtesbrot%2Fmoleculer-minio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/designtesbrot","download_url":"https://codeload.github.com/designtesbrot/moleculer-minio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249342985,"owners_count":21254391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["minio","moleculer","moleculerjs","s3-storage"],"created_at":"2024-08-02T02:00:44.025Z","updated_at":"2025-04-22T22:30:23.866Z","avatar_url":"https://github.com/designtesbrot.png","language":"JavaScript","funding_links":[],"categories":["Services"],"sub_categories":["Others"],"readme":"[![Moleculer logo](http://moleculer.services/images/banner.png)](https://github.com/moleculerjs/moleculer)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdesigntesbrot%2Fmoleculer-minio.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdesigntesbrot%2Fmoleculer-minio?ref=badge_shield)\n\n[![Build Status](https://travis-ci.com/designtesbrot/moleculer-minio.svg?branch=master)](https://travis-ci.com/designtesbrot/moleculer-minio)\n[![Coverage Status](https://coveralls.io/repos/github/designtesbrot/moleculer-minio/badge.svg?branch=master)](https://coveralls.io/github/designtesbrot/moleculer-minio?branch=master)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/7f8245b6a42249a7b3f5de62d88a9ef4)](https://www.codacy.com/app/designtesbrot/moleculer-minio?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=designtesbrot/moleculer-minio\u0026amp;utm_campaign=Badge_Grade)\n[![Maintainability](https://api.codeclimate.com/v1/badges/92a1e223f18762feb513/maintainability)](https://codeclimate.com/github/designtesbrot/moleculer-minio/maintainability)\n[![Known Vulnerabilities](https://snyk.io/test/github/designtesbrot/moleculer-minio/badge.svg)](https://snyk.io/test/github/designtesbrot/moleculer-minio)\n[![npm version](https://badge.fury.io/js/moleculer-minio.svg)](https://badge.fury.io/js/moleculer-minio)\n[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/39e921971bba8ef74126)\n\n# Minio Service for the Moleculer framework\n\nThis Services provides actions for managing buckets and objects in an AWS S3 or [Minio](https://www.minio.io) powered backend. It \nutilizes the file streaming capabilities of the moleculer framework\n\n## Features\n\nThe following List details which features are implemented\n\n- Bucket Management (Create, Delete, List)\n- Object Management (Put, List, Delete, Stat)\n- Presigned URL Management (Generate presigned URLs and Post Policy signed URLs)\n\n## Roadmap\n\nThe following List details which features are yet to be implemented\n\n- Caching\n- Broadcasting Bucket Notification as moleculer events\n\n## Requirements\n\nThis service relies on [Minio](https://www.minio.io) or a generic AWS S3 endpoint available. Make sure to configure the service properly in\norder to connect to your endpoint. Using Minio Gatewy capabilities, you can easily fan out to Azure and the like. This repository includes\nan example, which itself includes a docker-compose file connecting to an inlcuded minio backend.\n\n## Install\n\nThis package is available in the npm-registry. In order to use it simply install it with yarn (or npm):\n\n```bash\nyarn add moleculer-minio\n```\n\n## Usage\n\nTo make use of this Service, simply require it and create a new service:\n\n```js\nconst fs = require(\"fs\");\nlet { ServiceBroker } = require(\"moleculer\");\nlet MinioService = require(\"moleculer-minio\");\n\nlet broker = new ServiceBroker({ logger: console });\n\n// Create a service\nbroker.createService({\n    mixins: MinioService,\n    settings: {\n        // ... see settings for connectivity\n    }\n});\n\n// Start server\nbroker.start()\n    .then(() =\u003e broker.call('minio.makeBucket', {bucketName: 'my-bucket', region: 'us-east-1'}))\n    .then(() =\u003e \n        broker.call(\n            'minio.putObject', \n            fs.createReadStream('./archive.tar.gz'), \n            {\n                meta: {\n                    bucketName: 'my-bucket',\n                    objectName: 'my-object.tar.gz',\n                    metaData: {\n                        foo: 'bar'\n                    }\n                }\n            }\n        ))\n    .then(() =\u003e\n        broker.call('minio.presignedGetObject', {\n            bucketName: 'my-bucket',\n            objectName: 'my-object.tar.gz',\n            expires: 600\n        }))\n    .then(console.log);\n```\n\nFor a more indepth example checkout out the `examples folder`. It includes a docker-compose file, running `docker-compose up` will boot a broker with a minio service, a connected minio backend\nand an API Gateway to upload files to. This project includes a [published postman collection](https://app.getpostman.com/run-collection/39e921971bba8ef74126) enabling you to quickly explore the service in your local environment.\n\n## Settings\n\n\u003c!-- AUTO-CONTENT-START:SETTINGS --\u003e\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `endPoint` | `String` | **required** | The Hostname minio is running on and available at. Hostname or IP-Address |\n| `port` | `Number` | **required** | TCP/IP port number minio is listening on. Default value set to 80 for HTTP and 443 for HTTPs. |\n| `useSSL` | `Boolean` | `null` | If set to true, https is used instead of http. Default is true. |\n| `accessKey` | `String` | **required** | The AccessKey to use when connecting to minio |\n| `secretKey` | `String` | **required** | The SecretKey to use when connecting to minio |\n| `region` | `String` | `null` | Set this value to override region cache |\n| `transport` | `String` | `null` | Set this value to pass in a custom transport. (Optional) |\n| `sessionToken` | `String` | `null` | Set this value to provide x-amz-security-token (AWS S3 specific). (Optional) |\n| `minioHealthCheckInterval` | `Number` | `null` | This service will perform a periodic healthcheck of Minio. Use this setting to configure the inverval in which the healthcheck is performed. Set to `0` to turn healthcheks of |\n\n\u003c!-- AUTO-CONTENT-END:SETTINGS --\u003e\n\n\u003c!-- AUTO-CONTENT-TEMPLATE:SETTINGS\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n{{#each this}}\n| `{{name}}` | {{type}} | {{defaultValue}} | {{description}} |\n{{/each}}\n{{^this}}\n*No settings.*\n{{/this}}\n\n--\u003e\n\n## Actions\n\n\u003c!-- AUTO-CONTENT-START:ACTIONS --\u003e\n## `makeBucket` \n\nCreates a new Bucket\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | The name of the bucket |\n| `region` | `string` | **required** | The region to create the bucket in. Defaults to \"us-east-1\" |\n\n### Results\n**Type:** `PromiseLike.\u003c(undefined|Error)\u003e`\n\n\n\n\n## `listBuckets` \n\nLists all buckets.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n*No input parameters.*\n\n### Results\n**Type:** `PromiseLike.\u003c(Array.\u003cBucket\u003e|Error)\u003e`\n\n\n\n\n## `bucketExists` \n\nChecks if a bucket exists.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket |\n\n### Results\n**Type:** `PromiseLike.\u003c(boolean|Error)\u003e`\n\n\n\n\n## `removeBucket` \n\nRemoves a bucket.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket |\n\n### Results\n**Type:** `PromiseLike.\u003c(boolean|Error)\u003e`\n\n\n\n\n## `listObjects` \n\nLists all objects in a bucket.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket |\n| `prefix` | `string` | **required** | The prefix of the objects that should be listed (optional, default ''). |\n| `recursive` | `boolean` | **required** | `true` indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default `false`). |\n\n### Results\n**Type:** `PromiseLike.\u003c(Array.\u003cObject\u003e|Error)\u003e`\n\n\n\n\n## `listObjectsV2` \n\nLists all objects in a bucket using S3 listing objects V2 API\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket |\n| `prefix` | `string` | **required** | The prefix of the objects that should be listed (optional, default ''). |\n| `recursive` | `boolean` | **required** | `true` indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default `false`). |\n| `startAfter` | `string` | **required** | Specifies the object name to start after when listing objects in a bucket. (optional, default ''). |\n\n### Results\n**Type:** `PromiseLike.\u003c(Array.\u003cObject\u003e|Error)\u003e`\n\n\n\n\n## `listIncompleteUploads` \n\nLists partially uploaded objects in a bucket.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket |\n| `prefix` | `string` | **required** | The prefix of the objects that should be listed (optional, default ''). |\n| `recursive` | `boolean` | **required** | `true` indicates recursive style listing and false indicates directory style listing delimited by '/'. (optional, default `false`). |\n\n### Results\n**Type:** `PromiseLike.\u003c(Array.\u003cObject\u003e|Error)\u003e`\n\n\n\n\n## `getObject` \n\nDownloads an object as a stream.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket |\n| `objectName` | `string` | **required** | Name of the object. |\n\n### Results\n**Type:** `PromiseLike.\u003c(ReadableStream|Error)\u003e`\n\n\n\n\n## `getPartialObject` \n\nDownloads the specified range bytes of an object as a stream.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n| `offset` | `number` | **required** | `offset` of the object from where the stream will start. |\n| `length` | `number` | **required** | `length` of the object that will be read in the stream (optional, if not specified we read the rest of the file from the offset). |\n\n### Results\n**Type:** `PromiseLike.\u003c(ReadableStream|Error)\u003e`\n\n\n\n\n## `fGetObject` \n\nDownloads and saves the object as a file in the local filesystem.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n| `filePath` | `string` | **required** | Path on the local filesystem to which the object data will be written. |\n\n### Results\n**Type:** `PromiseLike.\u003c(undefined|Error)\u003e`\n\n\n\n\n## `putObject` \n\nUploads an object from a stream/Buffer.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `params` | `ReadableStream` | **required** | Readable stream. |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n| `size` | `number` | **required** | Size of the object (optional). |\n| `metaData` | `object` | **required** | metaData of the object (optional). |\n\n### Results\n**Type:** `PromiseLike.\u003c(undefined|Error)\u003e`\n\n\n\n\n## `fPutObject` \n\nUploads contents from a file to objectName.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n| `filePath` | `string` | **required** | Path of the file to be uploaded. |\n| `metaData` | `object` | **required** | metaData of the object (optional). |\n\n### Results\n**Type:** `PromiseLike.\u003c(undefined|Error)\u003e`\n\n\n\n\n## `copyObject` \n\nCopy a source object into a new object in the specified bucket.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n| `sourceObject` | `string` | **required** | Path of the file to be copied. |\n| `conditions` | `object` | **required** | Conditions to be satisfied before allowing object copy. |\n| `metaData` | `object` | **required** | metaData of the object (optional). |\n\n### Results\n**Type:** `PromiseLike.\u003c({etag: {string}, lastModified: {string}}|Error)\u003e`\n\n\n\n\n## `statObject` \n\nGets metadata of an object.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n\n### Results\n**Type:** `PromiseLike.\u003c({size: {number}, metaData: {object}, lastModified: {string}, etag: {string}}|Error)\u003e`\n\n\n\n\n## `removeObject` \n\nRemoves an Object\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n\n### Results\n**Type:** `PromiseLike.\u003c(undefined|Error)\u003e`\n\n\n\n\n## `removeObjects` \n\nRemoves a list of Objects\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectNames` | `Array.\u003cstring\u003e` | **required** | Names of the objects. |\n\n### Results\n**Type:** `PromiseLike.\u003c(undefined|Error)\u003e`\n\n\n\n\n## `removeIncompleteUpload` \n\nRemoves a partially uploaded object.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n\n### Results\n**Type:** `PromiseLike.\u003c(undefined|Error)\u003e`\n\n\n\n\n## `presignedUrl` \n\nGenerates a presigned URL for the provided HTTP method, 'httpMethod'. Browsers/Mobile clients may point to this URL to directly download objects even if the bucket is private. This\npresigned URL can have an associated expiration time in seconds after which the URL is no longer valid. The default value is 7 days.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `httpMethod` | `string` | **required** | The HTTP-Method (eg. `GET`). |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n| `expires` | `number` | **required** | Expiry time in seconds. Default value is 7 days. (optional) |\n| `reqParams` | `object` | **required** | request parameters. (optional) |\n| `requestDate` | `string` | **required** | An ISO date string, the url will be issued at. Default value is now. (optional) |\n\n### Results\n**Type:** `PromiseLike.\u003c(String|Error)\u003e`\n\n\n\n\n## `presignedGetObject` \n\nGenerates a presigned URL for HTTP GET operations. Browsers/Mobile clients may point to this URL to directly download objects even if the bucket is private. This presigned URL can have an\nassociated expiration time in seconds after which the URL is no longer valid. The default value is 7 days.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n| `expires` | `number` | **required** | Expiry time in seconds. Default value is 7 days. (optional) |\n| `reqParams` | `object` | **required** | request parameters. (optional) |\n| `requestDate` | `string` | **required** | An ISO date string, the url will be issued at. Default value is now. (optional) |\n\n### Results\n**Type:** `PromiseLike.\u003c(String|Error)\u003e`\n\n\n\n\n## `presignedPutObject` \n\nGenerates a presigned URL for HTTP PUT operations. Browsers/Mobile clients may point to this URL to upload objects directly to a bucket even if it is private. This presigned URL can have\nan associated expiration time in seconds after which the URL is no longer valid. The default value is 7 days.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `bucketName` | `string` | **required** | Name of the bucket. |\n| `objectName` | `string` | **required** | Name of the object. |\n| `expires` | `number` | **required** | Expiry time in seconds. Default value is 7 days. (optional) |\n\n### Results\n**Type:** `PromiseLike.\u003c(String|Error)\u003e`\n\n\n\n\n## `presignedPostPolicy` \n\nAllows setting policy conditions to a presigned URL for POST operations. Policies such as bucket name to receive object uploads, key name prefixes, expiry policy may be set.\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n| `policy` | `object` | **required** | Policy object created by minioClient.newPostPolicy() |\n\n### Results\n**Type:** `PromiseLike.\u003c({postURL: {string}, formData: {object}}|Error)\u003e`\n\n\n\n\n\u003c!-- AUTO-CONTENT-END:ACTIONS --\u003e\n\n\u003c!-- AUTO-CONTENT-TEMPLATE:ACTIONS\n{{#each this}}\n## `{{name}}` {{#each badges}}{{this}} {{/each}}\n{{#since}}\n_\u003csup\u003eSince: {{this}}\u003c/sup\u003e_\n{{/since}}\n\n{{description}}\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n{{#each params}}\n| `{{name}}` | {{type}} | {{defaultValue}} | {{description}} |\n{{/each}}\n{{^params}}\n*No input parameters.*\n{{/params}}\n\n{{#returns}}\n### Results\n**Type:** {{type}}\n\n{{description}}\n{{/returns}}\n\n{{#hasExamples}}\n### Examples\n{{#each examples}}\n{{this}}\n{{/each}}\n{{/hasExamples}}\n\n{{/each}}\n--\u003e\n\n# Methods\n\n\u003c!-- AUTO-CONTENT-START:METHODS --\u003e\n## `createMinioClient` \n\nCreates and returns a new Minio client\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n*No input parameters.*\n\n### Results\n**Type:** `Client`\n\n\n\n\n\u003c!-- AUTO-CONTENT-END:METHODS --\u003e\n\n\u003c!-- AUTO-CONTENT-TEMPLATE:METHODS\n{{#each this}}\n## `{{name}}` {{#each badges}}{{this}} {{/each}}\n{{#since}}\n_\u003csup\u003eSince: {{this}}\u003c/sup\u003e_\n{{/since}}\n\n{{description}}\n\n### Parameters\n| Property | Type | Default | Description |\n| -------- | ---- | ------- | ----------- |\n{{#each params}}\n| `{{name}}` | {{type}} | {{defaultValue}} | {{description}} |\n{{/each}}\n{{^params}}\n*No input parameters.*\n{{/params}}\n\n{{#returns}}\n### Results\n**Type:** {{type}}\n\n{{description}}\n{{/returns}}\n\n{{#hasExamples}}\n### Examples\n{{#each examples}}\n{{this}}\n{{/each}}\n{{/hasExamples}}\n\n{{/each}}\n--\u003e\n\n## Test\n```\n$ docker-compose exec package yarn test\n```\n\nIn development with watching\n\n```\n$ docker-compose up\n```\n\n## License\nmoleculer-minio is available under the [MIT license](https://tldrlegal.com/license/mit-license).\n\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdesigntesbrot%2Fmoleculer-minio.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdesigntesbrot%2Fmoleculer-minio?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesigntesbrot%2Fmoleculer-minio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesigntesbrot%2Fmoleculer-minio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesigntesbrot%2Fmoleculer-minio/lists"}