Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ jobs:

- uses: pnpm/action-setup@v6
with:
version: 10.33.0
version: 10

- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: pnpm

- run: pnpm install --shamefully-hoist=true
- run: pnpm run lint && pnpm run build

- run: pnpm run lint
- run: pnpm run build
- run: pnpm run test

release:
name: release
if: ${{ github.ref == 'refs/heads/master' }}
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ jobs:
contents: read
id-token: write
steps:
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
registry-url: https://registry.npmjs.org/
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies
run: npm install
- name: Publish Package to NPM Registry
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
registry-url: https://registry.npmjs.org/
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies
run: npm install
- name: Publish Package to NPM Registry
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
66 changes: 42 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,35 @@

</p>


<p align="center">
<a href="https://www.buymeacoffee.com/XbgWxt567" target="_blank"><img src="https://i.imgur.com/CahshSS.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>

</p>


## Description

This's a [nest-minio](https://github.com/rubiin/nest-minio) module for [Nest](https://github.com/nestjs/nest).
This quickstart guide will show you how to install the client SDK and execute an example JavaScript program. For a complete list of APIs and examples, please take a look at the [JavaScript Client API Reference](https://docs.min.io/docs/javascript-client-api-reference) documentation.

This document assumes that you have a working [nodejs](http://nodejs.org/) setup in place.


## Installation

```bash
$ npm i --save nestjs-minio
```


## Initialize MinIO Client

You need five items in order to connect to MinIO object storage server.


| Params | Description |
| :------- | :------------ |
| endPoint | URL to object storage service. |
|port| TCP/IP port number. This input is optional. Default value set to ``80`` for HTTP and ``443`` for HTTPs.|
| accessKey | Access key is like user ID that uniquely identifies your account. |
| secretKey | Secret key is the password to your account. |
|useSSL |Set this value to 'true' to enable secure (HTTPS) access |
| Params | Description |
| :-------- | :-------------------------------------------------------------------------------------------------- |
| endPoint | URL to object storage service. |
| port | TCP/IP port number. This input is optional. Default value set to `80` for HTTP and `443` for HTTPs. |
| accessKey | Access key is like user ID that uniquely identifies your account. |
| secretKey | Secret key is the password to your account. |
| useSSL | Set this value to 'true' to enable secure (HTTPS) access |

Provide the credentials for minio module by importing it as :

Expand All @@ -54,21 +50,21 @@ import { NestMinioClientController } from './nest-minio-client.controller';
import { NestMinioModule } from '../nest-minio.module';

@Module({
controllers: [NestMinioClientController],
imports: [
NestMinioModule.register({
isGlobal: true,
endPoint: 'play.min.io',
port: 9000,
useSSL: true,
accessKey: 'Q3AM3UQ867SPQQA43P2F',
secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
}),
],
controllers: [NestMinioClientController],
imports: [
NestMinioModule.register({
isGlobal: true,
endPoint: 'play.min.io',
port: 9000,
useSSL: true,
accessKey: 'Q3AM3UQ867SPQQA43P2F',
secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
}),
],
})
export class NestMinioClientModule {}

```

Then you can use it in the controller or service by injecting it in the controller as:

```javascript
Expand All @@ -77,7 +73,29 @@ Then you can use it in the controller or service by injecting it in the controll

```

## Connection Teardown

`NestMinioService` exposes manual teardown methods so applications can proactively close MinIO connections during graceful shutdown:

```typescript
import { Injectable } from '@nestjs/common';
import { NestMinioService } from 'nestjs-minio';

@Injectable()
export class ShutdownService {
constructor(private readonly minioService: NestMinioService) {}

async closeMinio(): Promise<void> {
await this.minioService.disconnect();
// Aliases: close() and destroy()
}
}
```

The module also performs this cleanup automatically on application shutdown.

## Quick Start Example - File Uploader

This example program connects to an object storage server, makes a bucket on the server and then uploads a file to the bucket.

We will use the MinIO server running at https://play.min.io in this example. Feel free to use this service for testing and development. Access credentials shown in this example are open to the public.
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ services:
minio:
image: minio/minio:latest
ports:
- "9000:9000"
- '9000:9000'
volumes:
- minio_data:/data
environment:
MINIO_ROOT_USER: "test"
MINIO_ROOT_PASSWORD: "test1234"
MINIO_ROOT_USER: 'test'
MINIO_ROOT_PASSWORD: 'test1234'
command: server /data
networks:
- minio-net
Expand Down
6 changes: 3 additions & 3 deletions nest-cli.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"language": "ts",
"collection": "@nestjs/schematics",
"sourceRoot": "src"
"language": "ts",
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}
83 changes: 46 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@
"name": "nestjs-minio",
"version": "2.7.6",
"description": "Minio object storage with nestjs",
"author": "Rubin Bhandari",
"keywords": [
"minio",
"nestjs"
],
"bugs": {
"url": "https://github.com/NestCrafts/nestjs-minio/issues"
},
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"author": "Rubin Bhandari",
"repository": {
"type": "git",
"url": "git+https://github.com/NestCrafts/nestjs-minio.git"
},
"files": [
"dist"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "npx rimraf dist tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json",
"prepack": "npm run build",
Expand All @@ -23,35 +37,23 @@
"test:e2e:dev": "jest --config ./tests/jest-e2e.json --runInBand --watch",
"build:docs": "npx compodoc -p tsconfig.build.json -d docs -o -s --theme material"
},
"keywords": [
"nestjs",
"minio"
],
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"@nestjs/common": ">7.0.0",
"@nestjs/core": ">7.0.0"
},
"dependencies": {
"minio": "^8.0.7"
},
"devDependencies": {
"@compodoc/compodoc": "^1.2.1",
"@nestjs/common": "^11.1.19",
"@nestjs/core": "^11.1.19",
"@nestjs/testing": "10.3.8",
"@rubiin/tsconfig": "^2.0.1",
"@rubiin/tsconfig": "^2.1.0",
"@types/express": "4.17.21",
"@types/jest": "29.5.12",
"@types/supertest": "6.0.2",
"cz-conventional-changelog": "3.3.0",
"husky": "^9.1.7",
"jest": "^30.3.0",
"lint-staged": "^16.4.0",
"oxfmt": "^0.45.0",
"oxlint": "^1.60.0",
"oxfmt": "^0.46.0",
"oxlint": "^1.61.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2",
"supertest": "^7.2.2",
Expand All @@ -60,19 +62,9 @@
"tsconfig-paths": "^4.2.0",
"typescript": "^6.0.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
"peerDependencies": {
"@nestjs/common": ">7.0.0",
"@nestjs/core": ">7.0.0"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
Expand All @@ -88,11 +80,28 @@
"path": "./node_modules/cz-conventional-changelog"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/NestCrafts/nestjs-minio.git"
},
"bugs": {
"url": "https://github.com/NestCrafts/nestjs-minio/issues"
"jest": {
"coverageDirectory": "../coverage",
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testEnvironment": "node",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": [
"ts-jest",
{
"tsconfig": "<rootDir>/../tsconfig.spec.json",
"diagnostics": {
"ignoreCodes": [
151002
]
}
}
]
}
}
}
Loading
Loading