Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@voidwalkers/void-client

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@voidwalkers/void-client

Client lib for Void Walkers Void

  • 0.1.23
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

Client lib for Void Walkers Void

Initialize client

void-cli init
void-cli config print client
import VoidClient from '@voidwalkers/void-client';

const voidClient = new VoidClient({
  project: {
    slug: 'test',
    tokenPublic: 'token'
  }
});

Auth

await voidClient.auth.signUpCustom({ // Example payload. Depends on implementation
  email: 'user@example.com',
  password: 'test1234'
});

const user = await voidClient.auth.getCurrentUser();
console.log(user); // {id: 'UUID'}

await voidClient.auth.signOut(true); // Ignores missing session, false by default

await voidClient.auth.signInCustom({ // Example payload. Depends on implementation
  email: 'user@example.com',
  password: 'test1234'
});

Functions

import {registerHttpFunction} from '@voidwalkers/void-functions';

registerCallFunction('echo', (data, context) => ({context, data}));
void-cli deploy -F echo
const result = await voidClient.function('echo')({hello: 'world'});

console.log(result); // {context: {projectUser: {id: 'UUID'}}, data: {hello: 'world'}}

Mongo

await voidClient.mongo.collection('items').deleteMany({type: 'box'});

await voidClient.mongo.collection('items').deleteOne({_id: 'MONGO_ID'});

await voidClient.mongo.collection('items').find({type: 'box'}, {
  // limit, skip, sort, projection
});

await voidClient.mongo.collection('items').findOne({_id: 'MONGO_ID'});

await voidClient.mongo.collection('items').findOneAndUpdate({_id: 'MONGO_ID'}, {
  $set: {
    name: 'updated box'
  }
}, {
  // upsert, includeResultMetadata, projection, returnDocument
});

await voidClient.mongo.collection('items').insertMany([{
  type: 'box',
  name: 'box 1'
}, {
  type: 'box',
  name: 'box 2'
}]);

await voidClient.mongo.collection('items').insertOne({
  type: 'box',
  name: 'empty box'
});

await voidClient.mongo.collection('items').replaceOne({_id: 'MONGO_ID'}, {
  type: 'bag',
  name: 'a bag'
}, {
  // upsert
});

await voidClient.mongo.collection('items').updateMany({_id: 'MONGO_ID'}, {
  $set: {
    name: 'updated box'
  }
}, {
  // upsert
});

await voidClient.mongo.collection('items').updateOne({_id: 'MONGO_ID'}, {
  $set: {
    name: 'updated box'
  }
}, {
  // upsert
});

voidClient.mongo.collection('items').watch({
  type: 'box'
}, ({data, type}) => {
  // type: "insert" | "update" | "delete"
  // data: document involved
}, {
  // let, projection
});

// Use database other than "default"

const candiesCollection = voidClient.mongo.db('another').collection('goods');

Storage

void-cli storage buckets create photos -t public
await voidClient.storage.bucket('photos').createFile(
  blobOrStream,
  'kitten-1.jpg',
  ['kittens', 'tiny'] // Optional, default []
); // https://void.void-walkers.com/projects/test/buckets/public/photos/kittens/tiny/kitten-1.jpg

await voidClient.storage.bucket('photos').deleteFile(
  'kitten-1.jpg',
  ['kittens', 'tiny'] // Optional, default []
);

await voidClient.storage.bucket('photos').listFiles({
  limit: 100, // Optional, default 50
  offset: 200, // Optional, default 0
  name: 'kitten-1.jpeg', // Optional, default null
  prefix: ['kittens', 'tiny'] // Optional, default []
});

await voidClient.storage.bucket('photos').updateFile(
  blobOrStream,
  'kitten-1.jpg',
  ['kittens', 'tiny'] // Optional, default []
);

FAQs

Package last updated on 15 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc