smartexpose/ts/classes.smartexpose.ts
2024-04-26 13:51:45 +02:00

50 lines
1.4 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);
}
public async exposeFileArray(optionsArg: Parameters<ExposeProvider['exposeFileArray']>[0]) {
return this.provider.exposeFileArray(optionsArg);
}
}