20 Commits

Author SHA1 Message Date
de4632d186 2.0.1 2022-04-14 10:38:14 +02:00
e69ca55a40 fix(structure): format 2022-04-14 10:38:14 +02:00
5803ef597f 2.0.0 2022-04-14 10:36:24 +02:00
0bb6bfbb37 BREAKING CHANGE(core): switch to esm 2022-04-14 10:36:24 +02:00
703bfe7fe8 1.0.10 2021-12-20 19:36:54 +01:00
545f5d35f5 fix(core): update 2021-12-20 19:36:54 +01:00
070eb559b9 1.0.9 2021-12-20 18:29:19 +01:00
d07e30d7fb fix(core): update 2021-12-20 18:29:18 +01:00
2293ad69e1 1.0.8 2021-12-20 18:25:55 +01:00
0a150a8a09 fix(core): update 2021-12-20 18:25:55 +01:00
b5f53b1f64 1.0.7 2021-12-20 17:06:43 +01:00
e5a02a014a fix(core): update 2021-12-20 17:06:42 +01:00
9d12338630 1.0.6 2021-12-20 16:38:52 +01:00
3c75bfedfc fix(core): update 2021-12-20 16:38:51 +01:00
d9e80caa6f 1.0.5 2021-12-20 16:33:13 +01:00
e44b7875e6 fix(core): update 2021-12-20 16:33:13 +01:00
52bad357fe 1.0.4 2021-12-18 02:17:42 +01:00
3ffc38dac5 fix(core): update 2021-12-18 02:17:42 +01:00
f35dd1e050 1.0.3 2021-12-18 01:48:03 +01:00
66eba9eef7 fix(core): update 2021-12-18 01:48:03 +01:00
10 changed files with 6934 additions and 14217 deletions

View File

@ -100,10 +100,9 @@ codequality:
only: only:
- tags - tags
script: script:
- npmci command npm install -g tslint typescript - npmci command npm install -g typescript
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags: tags:
- lossless - lossless
- docker - docker

View File

@ -5,7 +5,7 @@
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "pushrocks",
"gitrepo": "smarts3", "gitrepo": "smarts3",
"shortDescription": "create an s3 endpoint that maps to a local directory", "description": "create an s3 endpoint that maps to a local directory",
"npmPackagename": "@pushrocks/smarts3", "npmPackagename": "@pushrocks/smarts3",
"license": "MIT", "license": "MIT",
"projectDomain": "push.rocks" "projectDomain": "push.rocks"

21034
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,11 @@
{ {
"name": "@pushrocks/smarts3", "name": "@pushrocks/smarts3",
"version": "1.0.2", "version": "2.0.1",
"private": false, "private": false,
"description": "create an s3 endpoint that maps to a local directory", "description": "create an s3 endpoint that maps to a local directory",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
@ -12,12 +13,11 @@
"build": "(tsbuild --web)" "build": "(tsbuild --web)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.61",
"@gitzone/tsbundle": "^1.0.78", "@gitzone/tsbundle": "^1.0.102",
"@gitzone/tstest": "^1.0.44", "@gitzone/tstest": "^1.0.70",
"@pushrocks/smartbucket": "^1.0.44", "@pushrocks/tapbundle": "^5.0.3",
"@pushrocks/tapbundle": "^3.2.9", "@types/node": "^17.0.24",
"@types/node": "^17.0.0",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
@ -37,7 +37,9 @@
"readme.md" "readme.md"
], ],
"dependencies": { "dependencies": {
"@pushrocks/smartfile": "^9.0.3", "@pushrocks/smartbucket": "^2.0.1",
"@pushrocks/smartfile": "^9.0.6",
"@pushrocks/smartpath": "^5.0.5",
"@types/s3rver": "^3.7.0", "@types/s3rver": "^3.7.0",
"s3rver": "^3.7.1" "s3rver": "^3.7.1"
} }

View File

@ -1,5 +1,3 @@
import * as smartbucket from '@pushrocks/smartbucket'; import * as smartbucket from '@pushrocks/smartbucket';
export { export { smartbucket };
smartbucket
};

View File

@ -1,28 +1,23 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import * as plugins from './plugins'; import * as plugins from './plugins.js';
import * as smarts3 from '../ts/index'; import * as smarts3 from '../ts/index.js';
let testSmarts3Instance: smarts3.Smarts3; let testSmarts3Instance: smarts3.Smarts3;
tap.test('should create a smarts3 instance and run it', async toolsArg => { tap.test('should create a smarts3 instance and run it', async (toolsArg) => {
testSmarts3Instance = new smarts3.Smarts3({ testSmarts3Instance = await smarts3.Smarts3.createAndStart({
port: 3000, port: 3000,
cleanSlate: true, cleanSlate: true,
}); });
await testSmarts3Instance.start();
console.log(`Let the instance run for 2 seconds`); console.log(`Let the instance run for 2 seconds`);
await toolsArg.delayFor(2000); await toolsArg.delayFor(2000);
}); });
tap.test('should be able to access buckets', async () => { tap.test('should be able to access buckets', async () => {
const smartbucketInstance = new plugins.smartbucket.SmartBucket({ const smartbucketInstance = new plugins.smartbucket.SmartBucket(
endpoint: 'localhost', await testSmarts3Instance.getS3Descriptor()
port: 3000, );
useSsl: false,
accessKey: 'S3RVER',
accessSecret: 'S3RVER'
});
const bucket = await smartbucketInstance.createBucket('testbucket'); const bucket = await smartbucketInstance.createBucket('testbucket');
const baseDirectory = await bucket.getBaseDirectory(); const baseDirectory = await bucket.getBaseDirectory();
await baseDirectory.fastStore('subdir/hello.txt', 'hi there!'); await baseDirectory.fastStore('subdir/hello.txt', 'hi there!');
@ -30,6 +25,6 @@ tap.test('should be able to access buckets', async () => {
tap.test('should stop the instance', async () => { tap.test('should stop the instance', async () => {
await testSmarts3Instance.stop(); await testSmarts3Instance.stop();
}) });
tap.start(); tap.start();

View File

@ -1,5 +1,5 @@
import * as plugins from './smarts3.plugins'; import * as plugins from './smarts3.plugins.js';
import * as paths from './paths'; import * as paths from './paths.js';
export interface ISmarts3ContructorOptions { export interface ISmarts3ContructorOptions {
port?: number; port?: number;
@ -7,11 +7,23 @@ export interface ISmarts3ContructorOptions {
} }
export class Smarts3 { export class Smarts3 {
// STATIC
public static async createAndStart(optionsArg: ConstructorParameters<typeof Smarts3>[0]) {
const smartS3Instance = new Smarts3(optionsArg);
await smartS3Instance.start();
return smartS3Instance;
}
// INSTANCE
public options: ISmarts3ContructorOptions; public options: ISmarts3ContructorOptions;
public s3Instance: plugins.s3rver; public s3Instance: plugins.s3rver;
constructor(optionsArg: ISmarts3ContructorOptions) { constructor(optionsArg: ISmarts3ContructorOptions) {
this.options = optionsArg; this.options = optionsArg;
this.options = {
...this.options,
...optionsArg,
};
} }
public async start() { public async start() {
@ -25,13 +37,28 @@ export class Smarts3 {
address: '0.0.0.0', address: '0.0.0.0',
silent: false, silent: false,
directory: paths.bucketsDir, directory: paths.bucketsDir,
allowMismatchedSignatures: true, });
})
await this.s3Instance.run(); await this.s3Instance.run();
console.log('s3 server is running'); console.log('s3 server is running');
} }
public async getS3Descriptor(): Promise<plugins.smartbucket.ISmartBucketConfig> {
return {
accessKey: 'S3RVER',
accessSecret: 'S3RVER',
endpoint: 'localhost',
port: this.options.port,
useSsl: false,
};
}
public async createBucket(bucketNameArg: string) {
const smartbucketInstance = new plugins.smartbucket.SmartBucket(await this.getS3Descriptor());
const bucket = await smartbucketInstance.createBucket(bucketNameArg);
return bucket;
}
public async stop() { public async stop() {
await this.s3Instance.close(); await this.s3Instance.close();
} }
} }

View File

@ -1,6 +1,9 @@
import * as plugins from './smarts3.plugins'; import * as plugins from './smarts3.plugins.js';
export const packageDir = plugins.path.join(__dirname, '../'); export const packageDir = plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'../'
);
export const nogitDir = plugins.path.join(packageDir, './.nogit'); export const nogitDir = plugins.path.join(packageDir, './.nogit');
export const bucketsDir = plugins.path.join(nogitDir, './bucketsDir'); export const bucketsDir = plugins.path.join(nogitDir, './bucketsDir');

View File

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

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}