Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
070eb559b9 | |||
d07e30d7fb | |||
2293ad69e1 | |||
0a150a8a09 | |||
b5f53b1f64 | |||
e5a02a014a | |||
9d12338630 | |||
3c75bfedfc |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@pushrocks/smarts3",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.9",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@pushrocks/smarts3",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.9",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartfile": "^9.0.3",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smarts3",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.9",
|
||||
"private": false,
|
||||
"description": "create an s3 endpoint that maps to a local directory",
|
||||
"main": "dist_ts/index.js",
|
||||
|
11
test/test.ts
11
test/test.ts
@ -6,23 +6,16 @@ import * as smarts3 from '../ts/index';
|
||||
let testSmarts3Instance: smarts3.Smarts3;
|
||||
|
||||
tap.test('should create a smarts3 instance and run it', async toolsArg => {
|
||||
testSmarts3Instance = new smarts3.Smarts3({
|
||||
testSmarts3Instance = await smarts3.Smarts3.createAndStart({
|
||||
port: 3000,
|
||||
cleanSlate: true,
|
||||
});
|
||||
await testSmarts3Instance.start();
|
||||
console.log(`Let the instance run for 2 seconds`);
|
||||
await toolsArg.delayFor(2000);
|
||||
});
|
||||
|
||||
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!');
|
||||
|
24
ts/index.ts
24
ts/index.ts
@ -7,13 +7,15 @@ export interface ISmarts3ContructorOptions {
|
||||
}
|
||||
|
||||
export class Smarts3 {
|
||||
public options: ISmarts3ContructorOptions;
|
||||
public dataForClient = {
|
||||
s3AccessKey: 'S3RVER',
|
||||
s3AccessSecret: 'S3RVER',
|
||||
port: 3000,
|
||||
useSsl: false
|
||||
// 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 s3Instance: plugins.s3rver;
|
||||
|
||||
constructor(optionsArg: ISmarts3ContructorOptions) {
|
||||
@ -40,13 +42,13 @@ export class Smarts3 {
|
||||
console.log('s3 server is running');
|
||||
}
|
||||
|
||||
public async getLocalS3Descriptor(): Promise<plugins.smartbucket.ISmartBucketConfig> {
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user