smartexpose/ts/classes.smartexpose.ts

52 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-04-22 11:13:00 +00:00
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,
2024-04-24 16:02:21 +00:00
exposedBaseUrl: string,
2024-04-22 11:13:00 +00:00
}
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);
2024-04-24 16:02:21 +00:00
provider.smartExposeRef = smartexposeInstance;
2024-04-22 11:13:00 +00:00
return smartexposeInstance;
}
// INSTANCE
public taskmanager: plugins.taskbuffer.TaskManager;
2024-04-24 16:02:21 +00:00
public provider: ExposeProvider;
2024-04-22 11:13:00 +00:00
public options: ISmartExposeOptions;
constructor(provider: ExposeProvider, optionsArg: ISmartExposeOptions) {
2024-04-24 16:02:21 +00:00
this.provider = provider;
2024-04-22 11:13:00 +00:00
this.options = optionsArg;
}
2024-04-24 16:02:21 +00:00
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);
}
2024-04-22 11:13:00 +00:00
}