smartexpose/ts/classes.smartexpose.ts
2024-04-24 18:14:57 +02:00

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);
}
}