Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
dfadca9b80 | |||
a7579d2e12 | |||
de4632d186 | |||
e69ca55a40 | |||
5803ef597f | |||
0bb6bfbb37 | |||
703bfe7fe8 | |||
545f5d35f5 | |||
070eb559b9 | |||
d07e30d7fb | |||
2293ad69e1 | |||
0a150a8a09 |
@ -100,10 +100,9 @@ codequality:
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
|
@ -5,7 +5,7 @@
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"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",
|
||||
"license": "MIT",
|
||||
"projectDomain": "push.rocks"
|
||||
|
21034
package-lock.json
generated
21034
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -1,22 +1,23 @@
|
||||
{
|
||||
"name": "@pushrocks/smarts3",
|
||||
"version": "1.0.7",
|
||||
"version": "2.0.2",
|
||||
"private": false,
|
||||
"description": "create an s3 endpoint that maps to a local directory",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web)"
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsbundle": "^1.0.78",
|
||||
"@gitzone/tstest": "^1.0.44",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^17.0.0",
|
||||
"@gitzone/tsbuild": "^2.1.61",
|
||||
"@gitzone/tsbundle": "^1.0.102",
|
||||
"@gitzone/tstest": "^1.0.70",
|
||||
"@pushrocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^17.0.24",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
@ -36,8 +37,9 @@
|
||||
"readme.md"
|
||||
],
|
||||
"dependencies": {
|
||||
"@pushrocks/smartbucket": "^1.0.44",
|
||||
"@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",
|
||||
"s3rver": "^3.7.1"
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
import * as smartbucket from '@pushrocks/smartbucket';
|
||||
|
||||
export {
|
||||
smartbucket
|
||||
};
|
||||
export { smartbucket };
|
||||
|
18
test/test.ts
18
test/test.ts
@ -1,11 +1,11 @@
|
||||
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;
|
||||
|
||||
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 = await smarts3.Smarts3.createAndStart({
|
||||
port: 3000,
|
||||
cleanSlate: true,
|
||||
@ -15,13 +15,9 @@ tap.test('should create a smarts3 instance and run it', async toolsArg => {
|
||||
});
|
||||
|
||||
tap.test('should be able to access buckets', async () => {
|
||||
const smartbucketInstance = new plugins.smartbucket.SmartBucket({
|
||||
endpoint: 'localhost',
|
||||
port: 3000,
|
||||
useSsl: false,
|
||||
accessKey: 'S3RVER',
|
||||
accessSecret: 'S3RVER'
|
||||
});
|
||||
const smartbucketInstance = new plugins.smartbucket.SmartBucket(
|
||||
await testSmarts3Instance.getS3Descriptor()
|
||||
);
|
||||
const bucket = await smartbucketInstance.createBucket('testbucket');
|
||||
const baseDirectory = await bucket.getBaseDirectory();
|
||||
await baseDirectory.fastStore('subdir/hello.txt', 'hi there!');
|
||||
@ -29,6 +25,6 @@ tap.test('should be able to access buckets', async () => {
|
||||
|
||||
tap.test('should stop the instance', async () => {
|
||||
await testSmarts3Instance.stop();
|
||||
})
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
36
ts/index.ts
36
ts/index.ts
@ -1,5 +1,5 @@
|
||||
import * as plugins from './smarts3.plugins';
|
||||
import * as paths from './paths';
|
||||
import * as plugins from './smarts3.plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
|
||||
export interface ISmarts3ContructorOptions {
|
||||
port?: number;
|
||||
@ -16,20 +16,14 @@ export class Smarts3 {
|
||||
|
||||
// INSTANCE
|
||||
public options: ISmarts3ContructorOptions;
|
||||
public dataForClient = {
|
||||
s3AccessKey: 'S3RVER',
|
||||
s3AccessSecret: 'S3RVER',
|
||||
port: 3000,
|
||||
useSsl: false
|
||||
}
|
||||
public s3Instance: plugins.s3rver;
|
||||
|
||||
constructor(optionsArg: ISmarts3ContructorOptions) {
|
||||
this.options = optionsArg;
|
||||
this.options = {
|
||||
...this.options,
|
||||
...optionsArg
|
||||
}
|
||||
...optionsArg,
|
||||
};
|
||||
}
|
||||
|
||||
public async start() {
|
||||
@ -42,23 +36,29 @@ export class Smarts3 {
|
||||
port: this.options.port || 3000,
|
||||
address: '0.0.0.0',
|
||||
silent: false,
|
||||
directory: paths.bucketsDir
|
||||
})
|
||||
directory: paths.bucketsDir,
|
||||
});
|
||||
await this.s3Instance.run();
|
||||
console.log('s3 server is running');
|
||||
}
|
||||
|
||||
public async getS3Descriptor(): Promise<plugins.smartbucket.ISmartBucketConfig> {
|
||||
return {
|
||||
accessKey: this.dataForClient.s3AccessKey,
|
||||
accessSecret: this.dataForClient.s3AccessSecret,
|
||||
accessKey: 'S3RVER',
|
||||
accessSecret: 'S3RVER',
|
||||
endpoint: 'localhost',
|
||||
port: this.dataForClient.port,
|
||||
useSsl: this.dataForClient.useSsl,
|
||||
}
|
||||
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() {
|
||||
await this.s3Instance.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 bucketsDir = plugins.path.join(nogitDir, './bucketsDir');
|
||||
|
@ -1,22 +1,16 @@
|
||||
// node native
|
||||
import * as path from 'path';
|
||||
|
||||
export {
|
||||
path
|
||||
}
|
||||
export { path };
|
||||
|
||||
// pushrocks scope
|
||||
import * as smartbucket from '@pushrocks/smartbucket';
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
|
||||
export {
|
||||
smartbucket,
|
||||
smartfile,
|
||||
}
|
||||
export { smartbucket, smartfile, smartpath };
|
||||
|
||||
// thirdparty scope
|
||||
import s3rver from 's3rver';
|
||||
|
||||
export {
|
||||
s3rver
|
||||
}
|
||||
export { s3rver };
|
||||
|
9
tsconfig.json
Normal file
9
tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user