@adonisjs/drive
Version:
A thin wrapper on top of Flydrive to work seamlessly with AdonisJS
55 lines (54 loc) • 2.11 kB
TypeScript
import type { ConfigProvider } from '@adonisjs/core/types';
import type { S3Driver } from 'flydrive/drivers/s3';
import type { FSDriver } from 'flydrive/drivers/fs';
import type { GCSDriver } from 'flydrive/drivers/gcs';
import type { S3DriverOptions } from 'flydrive/drivers/s3/types';
import type { GCSDriverOptions } from 'flydrive/drivers/gcs/types';
import type { DriverFactory, AdonisFSDriverOptions, ServiceConfigProvider, ServiceWithLocalServer, DriveManagerOptions } from './types.js';
/**
* Helper to remap known drive services to factory functions
*/
type ResolvedConfig<Services extends Record<string, DriverFactory>> = {
config: {
default: keyof Services;
fakes: DriveManagerOptions<Services>['fakes'];
services: {
[K in keyof Services]: Services[K] extends ServiceConfigProvider<infer A> ? A : Services[K];
};
};
locallyServed: ServiceWithLocalServer[];
};
/**
* Helper function to define configuration for FlyDrive
*/
export declare function defineConfig<Services extends Record<string, DriverFactory>>(config: {
default: keyof Services;
fakes?: DriveManagerOptions<Services>['fakes'];
services: {
[K in keyof Services]: ServiceConfigProvider<Services[K]> | Services[K];
};
}): ConfigProvider<ResolvedConfig<Services>>;
/**
* Config helpers to register file storage services within the
* config file.
*/
export declare const services: {
/**
* Configure the "fs" driver to store files on the
* local filesystem and serve files using the
* AdonisJS HTTP server
*/
fs: (config: AdonisFSDriverOptions) => ServiceConfigProvider<() => FSDriver>;
/**
* Configure the "s3" driver to store files inside
* a S3 bucket and serve files using S3 directly
* or a CDN.
*/
s3: (config: S3DriverOptions) => ServiceConfigProvider<() => S3Driver>;
/**
* Configure the "gcs" driver to store files inside
* a GCS bucket and serve files using GCS directly.
*/
gcs: (config: GCSDriverOptions) => ServiceConfigProvider<() => GCSDriver>;
};
export {};