diff --git a/npmextra.json b/npmextra.json index 730b011..f3394cc 100644 --- a/npmextra.json +++ b/npmextra.json @@ -5,17 +5,29 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smarts3", - "description": "create an s3 endpoint that maps to a local directory", + "description": "Creates an S3 endpoint that maps to a local directory for testing and local development.", "npmPackagename": "@push.rocks/smarts3", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "keywords": [ + "S3 Mock Server", + "Local S3", + "S3 Testing", + "Node.js", + "TypeScript", + "Local Development", + "Cloud Storage Simulation", + "File Storage", + "AWS S3 Compatibility", + "Development Tool" + ] } }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" }, - "tsdocs": { + "tsdoc": { "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" } } \ No newline at end of file diff --git a/package.json b/package.json index 16ff941..9a5f794 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smarts3", "version": "2.1.1", "private": false, - "description": "create an s3 endpoint that maps to a local directory", + "description": "Creates an S3 endpoint that maps to a local directory for testing and local development.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "type": "module", @@ -40,5 +40,17 @@ "@pushrocks/smartpath": "^5.0.5", "@types/s3rver": "^3.7.0", "s3rver": "^3.7.1" - } + }, + "keywords": [ + "S3 Mock Server", + "Local S3", + "S3 Testing", + "Node.js", + "TypeScript", + "Local Development", + "Cloud Storage Simulation", + "File Storage", + "AWS S3 Compatibility", + "Development Tool" + ] } \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index 0de13fb..fc8dec4 100644 --- a/readme.md +++ b/readme.md @@ -1,39 +1,114 @@ -# @pushrocks/smarts3 +# @push.rocks/smarts3 create an s3 endpoint that maps to a local directory -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smarts3) -* [gitlab.com (source)](https://gitlab.com/pushrocks/smarts3) -* [github.com (source mirror)](https://github.com/pushrocks/smarts3) -* [docs (typedoc)](https://pushrocks.gitlab.io/smarts3/) +## Install -## Status for master +To use @push.rocks/smarts3 in your project, you'll need to install it via npm. You can do so by running the following command in your project's root directory: -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smarts3/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smarts3/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smarts3)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smarts3)](https://lossless.cloud) -TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) -node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) -PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smarts3)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smarts3)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smarts3)](https://lossless.cloud) -Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud) +```sh +npm install @push.rocks/smarts3 --save +``` + +This will add `@push.rocks/smarts3` as a dependency to your project's `package.json` file and download the package into the `node_modules` directory. ## Usage -Use TypeScript for best in class intellisense +@push.rocks/smarts3 is designed to make it easy for developers to create an S3 compatible endpoint that maps to a local directory. This can be particularly useful for local development and testing, allowing you to mimic S3's functionality without the need for an actual S3 bucket. -## Contribution +Below, we'll go through how to get started, set up an S3 server, manage buckets, and perform common operations. -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +### Setting up the S3 Server -For further information read the linked docs at the top of this readme. +First, let's see how to set up and start an S3 server instance. -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +```typescript +import { Smarts3 } from '@push.rocks/smarts3'; -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) +async function startServer() { + // Creating and starting the Smarts3 instance + const smarts3Instance = await Smarts3.createAndStart({ + port: 3000, // optional, defaults to 3000 + cleanSlate: true // optional, if set to true, it will empty the directory on start + }); + + console.log('S3 server is up and running...'); + return smarts3Instance; +} + +startServer().catch(console.error); +``` + +### Creating a Bucket + +With the server up and running, you can now create buckets. + +```typescript +async function createBucket(smarts3Instance: Smarts3) { + // Creating a new bucket + const bucket = await smarts3Instance.createBucket('my-awesome-bucket'); + console.log(`Bucket created: ${bucket.name}`); +} + +// Assuming startServer() has been called and smarts3Instance has been received +createBucket(smarts3Instance).catch(console.error); +``` + +### Accessing Buckets and Uploading Files + +To perform actions like uploading files, you will need to work with the underlying `SmartBucket` module. The `SmartBucket` module is part of the @push.rocks ecosystem and integrated into smarts3 for easy bucket and file management. + +```typescript +import { SmartBucket, Bucket } from '@pushrocks/smartbucket'; + +async function uploadFile(smarts3Instance: Smarts3) { + // Getting the S3 descriptor to configure SmartBucket + const s3Descriptor = await smarts3Instance.getS3Descriptor(); + + const smartbucketInstance = new SmartBucket(s3Descriptor); + const bucket: Bucket = await smartbucketInstance.getBucket('my-awesome-bucket'); + + // Now let's upload a file to the bucket + const baseDirectory = await bucket.getBaseDirectory(); + await baseDirectory.fastStore('hello.txt', 'Hello, world!'); + + console.log('File uploaded successfully.'); +} + +uploadFile(smarts3Instance).catch(console.error); +``` + +### Stopping the Server + +Finally, when you are done, you can stop the Smarts3 server as follows: + +```typescript +async function stopServer(smarts3Instance: Smarts3) { + await smarts3Instance.stop(); + console.log('S3 server has been stopped.'); +} + +stopServer(smarts3Instance).catch(console.error); +``` + +### Complete Integration + +Integrating @push.rocks/smarts3 into your development workflow offers a seamless way to mimic Amazon S3 locally. By creating an S3-compatible endpoint that maps to a local directory, you can develop and test applications that interact with S3 without incurring any cost or requiring internet connectivity. Thanks to its API, @push.rocks/smarts3 makes it easy to programmatically manage your local S3 server, create and delete buckets, and upload or download files, ensuring that your applications can be designed with cloud scalability in mind, right from the start. + +## License and Legal Information + +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. + +**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. + +### Trademarks + +This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH. + +### Company Information + +Task Venture Capital GmbH +Registered at District court Bremen HRB 35230 HB, Germany + +For any legal inquiries or if you require further information, please contact us via email at hello@task.vc. + +By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.