fix(core): update
This commit is contained in:
parent
2bee288dac
commit
c9eb03dc31
20
test/test.ts
20
test/test.ts
@ -9,17 +9,17 @@ import * as smartexpose from '../ts/index.js'
|
|||||||
let testSmartexpose: smartexpose.SmartExpose;
|
let testSmartexpose: smartexpose.SmartExpose;
|
||||||
|
|
||||||
tap.test('should create a valid instance of smartexpose using Webdav', async () => {
|
tap.test('should create a valid instance of smartexpose using Webdav', async () => {
|
||||||
testSmartexpose = await smartexpose.SmartExpose.createWithWebdav({
|
testSmartexpose = new smartexpose.SmartExpose({
|
||||||
webdavCredentials: {
|
webdav: {
|
||||||
serverUrl: await testQenv.getEnvVarOnDemand('WEBDAV_SERVER_URL'),
|
webdavCredentials: {
|
||||||
password: await testQenv.getEnvVarOnDemand('WEBDAV_SERVER_TOKEN'),
|
serverUrl: await testQenv.getEnvVarOnDemand('WEBDAV_SERVER_URL'),
|
||||||
|
password: await testQenv.getEnvVarOnDemand('WEBDAV_SERVER_TOKEN'),
|
||||||
|
},
|
||||||
|
webdavSubPath: await testQenv.getEnvVarOnDemand('WEBDAV_SUB_PATH'),
|
||||||
},
|
},
|
||||||
webdavSubPath: await testQenv.getEnvVarOnDemand('WEBDAV_SUB_PATH'),
|
deleteAfterMillis: 30000,
|
||||||
exposeOptions: {
|
privateUrl: true,
|
||||||
deleteAfterMillis: 30000,
|
exposedBaseUrl: await testQenv.getEnvVarOnDemand('EXPOSED_BASE_URL'),
|
||||||
privateUrl: true,
|
|
||||||
exposedBaseUrl: await testQenv.getEnvVarOnDemand('EXPOSED_BASE_URL'),
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
await testSmartexpose.start();
|
await testSmartexpose.start();
|
||||||
expect(testSmartexpose).toBeInstanceOf(smartexpose.SmartExpose);
|
expect(testSmartexpose).toBeInstanceOf(smartexpose.SmartExpose);
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartexpose',
|
name: '@push.rocks/smartexpose',
|
||||||
version: '1.0.3',
|
version: '1.0.4',
|
||||||
description: 'a package to expose things to the internet'
|
description: 'a package to expose things to the internet'
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,9 @@ export class WebDavExposeProvider extends ExposeProvider {
|
|||||||
public webdavClient: plugins.smartwebdav.WebdavClient;
|
public webdavClient: plugins.smartwebdav.WebdavClient;
|
||||||
public options: IWebdavExposeProviderOptions;
|
public options: IWebdavExposeProviderOptions;
|
||||||
|
|
||||||
constructor(optionsArg: IWebdavExposeProviderOptions) {
|
constructor(smartexposeRefArg: SmartExpose, optionsArg: IWebdavExposeProviderOptions) {
|
||||||
super();
|
super();
|
||||||
|
this.smartExposeRef = smartexposeRefArg;
|
||||||
this.options = optionsArg;
|
this.options = optionsArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,36 +6,30 @@ export interface ISmartExposeOptions {
|
|||||||
deleteAfterMillis?: number,
|
deleteAfterMillis?: number,
|
||||||
privateUrl?: boolean,
|
privateUrl?: boolean,
|
||||||
exposedBaseUrl: string,
|
exposedBaseUrl: string,
|
||||||
|
webdav?: {
|
||||||
|
webdavCredentials: plugins.smartwebdav.IWebdavClientOptions,
|
||||||
|
webdavSubPath: string,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SmartExpose {
|
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
|
// INSTANCE
|
||||||
public taskmanager: plugins.taskbuffer.TaskManager;
|
public taskmanager: plugins.taskbuffer.TaskManager;
|
||||||
public provider: ExposeProvider;
|
public provider: ExposeProvider;
|
||||||
public options: ISmartExposeOptions;
|
public options: ISmartExposeOptions;
|
||||||
|
|
||||||
constructor(provider: ExposeProvider, optionsArg: ISmartExposeOptions) {
|
constructor(optionsArg: ISmartExposeOptions) {
|
||||||
this.provider = provider;
|
|
||||||
this.options = optionsArg;
|
this.options = optionsArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async start() {
|
public async start() {
|
||||||
this.taskmanager = new plugins.taskbuffer.TaskManager();
|
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();
|
await this.provider.start();
|
||||||
this.taskmanager.start();
|
this.taskmanager.start();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user