Skip to content

Commit 4b443e4

Browse files
committed
add function for adonisjs v6
1 parent 667b815 commit 4b443e4

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

+2-12
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,7 @@ const driver = new AzureDriver({
2222
## AdonisJs V6 Usage
2323

2424
```ts
25-
import { ServiceConfigProvider } from '@adonisjs/drive/types'
26-
import { AzureDriver, AzureStorageDriverConfig } from 'flydrive-azure-driver'
27-
28-
function azureService(config: AzureStorageDriverConfig): ServiceConfigProvider<() => AzureDriver> {
29-
return {
30-
type: 'provider',
31-
resolver: async () => {
32-
return () => new AzureDriver(config)
33-
},
34-
}
35-
}
25+
import { AzureService } from 'flydrive-azure'
3626

3727
const driveConfig = defineConfig({
3828
default: env.get('DRIVE_DISK', 'azure'),
@@ -42,7 +32,7 @@ const driveConfig = defineConfig({
4232
// other driver config
4333
....
4434

45-
azure: azureService({
35+
azure: AzureService({
4636
connectionString: env.get('AZURE_BLOB_STORAGE_CONN_STRING'),
4737
container: env.get('AZURE_BLOB_STORAGE_CONTAINER'),
4838
}),

src/index.ts

+14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { type AzureStorageDriverConfig, CannotCopyFileException, CannotDeleteFil
1212
import { DefaultAzureCredential } from '@azure/identity'
1313
import { buffer } from 'node:stream/consumers'
1414

15+
1516
export class AzureDriver implements DriverContract {
1617
/**
1718
* Reference to the Azure storage instance
@@ -298,6 +299,19 @@ export class AzureDriver implements DriverContract {
298299
}
299300
}
300301

302+
// for adonisjs v6
303+
export function AzureService (config: AzureStorageDriverConfig): {
304+
type: 'provider'
305+
resolver: () => Promise<() => AzureDriver>
306+
} {
307+
return {
308+
type: 'provider',
309+
resolver: async () => {
310+
return () => new AzureDriver(config)
311+
}
312+
}
313+
}
314+
301315
export {
302316
type AzureStorageDriverConfig, CannotCopyFileException, CannotDeleteFileException, CannotGetMetaDataException, CannotMoveFileException, CannotSetMetaDataException, CannotWriteFileException, FileNotFoundException, MethodNotImplementedException
303317
}

0 commit comments

Comments
 (0)