fix(core): update

This commit is contained in:
2021-12-18 01:41:50 +01:00
commit e0f6a501e0
15 changed files with 29444 additions and 0 deletions

37
ts/index.ts Normal file
View File

@ -0,0 +1,37 @@
import * as plugins from './smarts3.plugins';
import * as paths from './paths';
export interface ISmarts3ContructorOptions {
port?: number;
cleanSlate?: boolean;
}
export class Smarts3 {
public options: ISmarts3ContructorOptions;
public s3Instance: plugins.s3rver;
constructor(optionsArg: ISmarts3ContructorOptions) {
this.options = optionsArg;
}
public async start() {
if (this.options.cleanSlate) {
await plugins.smartfile.fs.ensureEmptyDir(paths.bucketsDir);
} else {
await plugins.smartfile.fs.ensureDir(paths.bucketsDir);
}
this.s3Instance = new plugins.s3rver({
port: this.options.port || 3000,
address: '0.0.0.0',
silent: false,
directory: paths.bucketsDir,
allowMismatchedSignatures: true,
})
await this.s3Instance.run();
console.log('s3 server is running');
}
public async stop() {
await this.s3Instance.close();
}
}

6
ts/paths.ts Normal file
View File

@ -0,0 +1,6 @@
import * as plugins from './smarts3.plugins';
export const packageDir = plugins.path.join(__dirname, '../');
export const nogitDir = plugins.path.join(packageDir, './.nogit');
export const bucketsDir = plugins.path.join(nogitDir, './bucketsDir');

20
ts/smarts3.plugins.ts Normal file
View File

@ -0,0 +1,20 @@
// node native
import * as path from 'path';
export {
path
}
// pushrocks scope
import * as samrtfile from '@pushrocks/smartfile';
export {
samrtfile as smartfile
}
// thirdparty scope
import s3rver from 's3rver';
export {
s3rver
}