46 lines
1.3 KiB
TypeScript
46 lines
1.3 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,
|
|
webdav?: {
|
|
webdavCredentials: plugins.smartwebdav.IWebdavClientOptions,
|
|
webdavSubPath: string,
|
|
}
|
|
}
|
|
|
|
export class SmartExpose {
|
|
// INSTANCE
|
|
public taskmanager: plugins.taskbuffer.TaskManager;
|
|
public provider: ExposeProvider;
|
|
public options: ISmartExposeOptions;
|
|
|
|
constructor(optionsArg: ISmartExposeOptions) {
|
|
this.options = optionsArg;
|
|
}
|
|
|
|
public async start() {
|
|
this.taskmanager = new plugins.taskbuffer.TaskManager();
|
|
if (this.options.webdav) {
|
|
this.provider = new WebDavExposeProvider(this, {
|
|
webdavCredentials: this.options.webdav.webdavCredentials,
|
|
webdavSubPath: this.options.webdav.webdavSubPath,
|
|
});
|
|
}
|
|
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);
|
|
}
|
|
}
|