52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import type { ExposeProvider } from './classes.exposeprovider.js';
|
|
import { WebDavExposeProvider } from './classes.exposeprovider.webdav.js';
|
|
import * as plugins from './plugins.js';
|
|
|
|
export interface ISmartExposeOptions {
|
|
deleteAfterMillis?: number,
|
|
privateUrl?: boolean,
|
|
exposedBaseUrl: string,
|
|
}
|
|
|
|
export class SmartExpose {
|
|
// STATIC
|
|
public static createWithWebdav(optionsArg: {
|
|
webdavCredentials: plugins.smartwebdav.IWebdavClientOptions,
|
|
webdavSubPath: string,
|
|
exposeOptions: ISmartExposeOptions,
|
|
}) {
|
|
const provider = new WebDavExposeProvider({
|
|
webdavCredentials: optionsArg.webdavCredentials,
|
|
webdavSubPath: optionsArg.webdavSubPath,
|
|
});
|
|
const smartexposeInstance = new SmartExpose(provider, optionsArg.exposeOptions);
|
|
provider.smartExposeRef = smartexposeInstance;
|
|
return smartexposeInstance;
|
|
}
|
|
|
|
// INSTANCE
|
|
public taskmanager: plugins.taskbuffer.TaskManager;
|
|
public provider: ExposeProvider;
|
|
public options: ISmartExposeOptions;
|
|
|
|
constructor(provider: ExposeProvider, optionsArg: ISmartExposeOptions) {
|
|
this.provider = provider;
|
|
this.options = optionsArg;
|
|
}
|
|
|
|
public async start() {
|
|
this.taskmanager = new plugins.taskbuffer.TaskManager();
|
|
await this.provider.start();
|
|
this.taskmanager.start();
|
|
}
|
|
|
|
public async stop() {
|
|
await this.provider.stop();
|
|
this.taskmanager.stop();
|
|
}
|
|
|
|
public async exposeFile(optionsArg: Parameters<ExposeProvider['exposeFile']>[0]) {
|
|
return this.provider.exposeFile(optionsArg);
|
|
}
|
|
}
|