-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
config.ts
37 lines (33 loc) · 863 Bytes
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* @adonisjs/drive
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { DriversList } from '@ioc:Adonis/Core/Drive'
/**
* Expected shape of the config accepted by the "driveConfig"
* method
*/
type DriveConfig = {
disks: {
[name: string]: {
[K in keyof DriversList]: DriversList[K]['config'] & { driver: K }
}[keyof DriversList]
}
}
/**
* Define config for AdonisJS drive
*/
export function driveConfig<T extends DriveConfig & { disk: keyof T['disks'] }>(config: T): T {
return config
}
/**
* Pull disks from the config defined inside the "config/drive.ts"
* file
*/
export type InferDisksFromConfig<T extends DriveConfig> = {
[K in keyof T['disks']]: DriversList[T['disks'][K]['driver']]
}