nebstore-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

NebStore Client

Nebstore Client is a JavaScript-based client that provides an easy-to-use interface for managing cloud storage services with NebStore. It enables you to create, list, and manage buckets and objects with simple method calls.

Features

  • Create, list, and delete buckets.
  • Upload, list, and delete objects.
  • Pagination support for list operations.
  • File uploads using FormData.

Installation

You can install the package using npm or yarn.

Using npm

npm install nebstore-client

using yarn

yarn add nebstore-client
import { NebStore } from 'nebstore-client'
const nebStore = new NebStore('your-api-token')

List Buckets

// List all buckets with pagination
const params = {
  page: 1,
  limit: 10,
  startDate: new Date('2024-01-01'),
  endDate: new Date(),
}

const response = await nebStore.listBuckets(params)
console.log(response)

Parameters

  • page: Page number.
  • limit: Number of buckets per page.
  • startDate: The start date to filter the list.
  • endDate: The end date to filter the list.

List Objects in a bucket

// Lists all objects in a specific bucket with pagination.
const params = {
  page: 1,
  limit: 10,
  startDate: new Date('2024-01-01'),
  endDate: new Date(),
}

const response = await nebStore.listObjects('bucketName', params)
console.log(response)

Parameters

  • bucketName: The name of the bucket.
  • params: An object containing pagination and filtering options (similar to listBuckets).

Create bucket

// Creates a new bucket with specified details.
const newBucket = {
  bucketName: 'my-new-bucket',
  region: 'sa-1',
  isPrivate: true,
}
const response = await nebStore.createBucket(newBucket)
console.log(response)

Parameters

  • params: An object containing:
    • bucketName: The name of the new bucket.
    • region: The region of the bucket (e.g., 'sa-1').
    • isPrivate: Optional boolean to set the bucket as private.

Empty bucket

// Empties all objects from a specified bucket.
const response = await nebStore.emptyBucket('bucketName')
console.log(response)

Parameters

  • bucketName: The name of the bucket to empty.

Get bucket

// Fetches the details of a specified bucket.
const response = await nebStore.getBucket('bucketName')
console.log(response)

Parameters

  • bucketName: The name of the bucket.

Get Object

// Fetches the details of a specific object in a bucket.
const response = await nebStore.getObject('bucketName', 'objectKey').console.log(response)

Parameters

  • bucketName: The name of the bucket.
  • objectKey: The key or name of the object.

Upload Object

// Uploads an object (file) to a specific bucket.
const fs = require('fs')
const file = fs.createReadStream('path/to/file.txt')

const response = await nebStore.uploadObject('my-new-bucket', 'my-object-key', file)
console.log(response)

Parameters

  • bucketName: The name of the bucket.
  • objectKey: The key or name to assign to the object.
  • file: The file to be uploaded (as Buffer, Blob, or ReadableStream).

Delete bucket

// Deletes a specified bucket.
const response = await nebStore.deleteBucket('bucketName')
console.log(response)

Parameters

  • bucketName: The name of the bucket.

Delete Object

// Deletes a specific object from a bucket.
const response = await nebStore.deleteObject('bucketName', 'objectKey')
console.log(response)

Parameters

  • bucketName: The name of the bucket.
  • objectKey: The key or name of the object to delete.

/nebstore-client/

    Package Sidebar

    Install

    npm i nebstore-client

    Weekly Downloads

    2

    Version

    1.0.9

    License

    MIT

    Unpacked Size

    17 kB

    Total Files

    15

    Last publish

    Collaborators

    • oreace