BREAKING CHANGE(Smarts3): Remove legacy s3rver backend, simplify Smarts3 server API, and bump dependencies

This commit is contained in:
2025-11-21 14:36:30 +00:00
parent 654f47b7fc
commit c3daf9d3f7
7 changed files with 81 additions and 159 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smarts3',
version: '2.3.0',
version: '3.0.0',
description: 'A Node.js TypeScript package to create a local S3 endpoint for simulating AWS S3 operations using mapped local directories for development and testing purposes.'
}

View File

@@ -5,7 +5,6 @@ import { Smarts3Server } from './classes/smarts3-server.js';
export interface ISmarts3ContructorOptions {
port?: number;
cleanSlate?: boolean;
useCustomServer?: boolean; // Feature flag for custom server
}
export class Smarts3 {
@@ -20,65 +19,30 @@ export class Smarts3 {
// INSTANCE
public options: ISmarts3ContructorOptions;
public s3Instance: plugins.s3rver | Smarts3Server;
public s3Instance: Smarts3Server;
constructor(optionsArg: ISmarts3ContructorOptions) {
this.options = {
useCustomServer: true, // Default to custom server
...optionsArg,
};
this.options = optionsArg;
}
public async start() {
if (this.options.useCustomServer) {
// Use new custom server
this.s3Instance = new Smarts3Server({
port: this.options.port || 3000,
address: '0.0.0.0',
directory: paths.bucketsDir,
cleanSlate: this.options.cleanSlate || false,
silent: false,
});
await this.s3Instance.start();
console.log('s3 server is running (custom implementation)');
} else {
// Use legacy s3rver
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,
});
await (this.s3Instance as plugins.s3rver).run();
console.log('s3 server is running (legacy s3rver)');
}
this.s3Instance = new Smarts3Server({
port: this.options.port || 3000,
address: '0.0.0.0',
directory: paths.bucketsDir,
cleanSlate: this.options.cleanSlate || false,
silent: false,
});
await this.s3Instance.start();
console.log('s3 server is running');
}
public async getS3Descriptor(
optionsArg?: Partial<plugins.tsclass.storage.IS3Descriptor>,
): Promise<plugins.tsclass.storage.IS3Descriptor> {
if (this.options.useCustomServer && this.s3Instance instanceof Smarts3Server) {
const descriptor = this.s3Instance.getS3Descriptor();
return {
...descriptor,
...(optionsArg ? optionsArg : {}),
};
}
// Legacy s3rver descriptor
const descriptor = this.s3Instance.getS3Descriptor();
return {
...{
accessKey: 'S3RVER',
accessSecret: 'S3RVER',
endpoint: '127.0.0.1',
port: this.options.port || 3000,
useSsl: false,
},
...descriptor,
...(optionsArg ? optionsArg : {}),
};
}
@@ -92,11 +56,7 @@ export class Smarts3 {
}
public async stop() {
if (this.s3Instance instanceof Smarts3Server) {
await this.s3Instance.stop();
} else {
await (this.s3Instance as plugins.s3rver).close();
}
await this.s3Instance.stop();
}
}

View File

@@ -19,8 +19,3 @@ export { smartbucket, smartfile, smartpath, SmartXml };
import * as tsclass from '@tsclass/tsclass';
export { tsclass };
// thirdparty scope
import s3rver from 's3rver';
export { s3rver };