npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

deepjson-connector

v1.0.8

Published

Official connector for DeepJSON Server - JSON storage with real-time sync

Readme

DeepJSON Server & Client

A high-performance JSON storage server with real-time synchronization capabilities and secure scripting support.

Features

  • JWT & HMAC Authentication
  • CRUD Operations for JSON Data
  • Binary File Handling (Images, Documents)
  • Secure Script Execution (VM2 Sandbox)
  • Real-time Synchronization Channels
  • Role-based Access Control

Installation

Node.js Client

npm install deepjson-connector

Browser Client

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
<script src="https://cdn.socket.io/4.7.2/socket.io.min.js"></script>
<script src="path/to/deepjson-client.js"></script>

Quick Start

Basic Connection

Node.js

const { Connector } = require('deepjson-client');

// Basic configuration
const dj = new Connector({
  baseURL: 'http://localhost:3000', // Server URL
  timeout: 15000, // Request timeout (ms)
  storage: 'local' // 'local' (persistent) or 'session' (tab-only)
});

// Advanced configuration
const djSecure = new Connector({
  baseURL: 'https://api.yourdomain.com',
  token: 'eyJhbGci...', // Preload existing JWT
  headers: {
    'X-Client-Version': '1.4.2'
  }
});

Browser

// Initialize with default settings
const dj = new DeepJSONConnector({
  baseURL: 'http://localhost:3000'
});

// Initialize with existing token (e.g., from localStorage)
const djAuthenticated = new DeepJSONConnector({
  baseURL: 'http://localhost:3000',
  token: localStorage.getItem('dj_token')
});

Authentification

// Basic username/password login
try {
  const response = await dj.login('[email protected]', 'securepassword123');
  console.log('Authenticated as:', response.user);
  console.log('JWT Token:', dj.getToken());
} catch (err) {
  console.error('Login failed:', err.message);
}

// Manual token handling (for existing sessions)
dj.token = 'eyJhbGciOiJIUzI1NiIsInR5c...';

Example Error Handling:

try {
  await dj.get('secured/data');
} catch (err) {
  if (err.status === 401) {
    console.log('Session expired - redirecting to login');
    window.location.href = '/login';
  } else {
    console.error('API Error:', err.details);
  }
}

Basic Operations

Create/Update Data:

// Create new entry
await dj.post('users/123', {
  name: 'Alice',
  roles: ['editor']
});

// Overwrite existing entry
const overwriteConfig = {
  overwriteKey: true
};
await dj.post('users/123', {
  name: 'Alicia' // Full replacement
}, overwriteConfig);

// Partial update
await dj.put('users/123', {
  roles: ['admin'] // Merge with existing data
});

Retrieve Data:

// Simple GET
const userData = await dj.get('users/123');

// Get with query parameters
const filteredData = await dj.get('logs', {
  params: {
    dateFrom: '2024-01-01',
    limit: 50
  }
});

Delete Data:

// Single entry
await dj.delete('users/123');

// Recursive delete (server must implement this)
await dj.delete('projects/old-project/*');

Move Data:

// Move key location
await dj.move('users/temp/guest1', 'users/registered/guest1');

// Verify move
try {
  const oldData = await dj.get('users/temp/guest1');
} catch (err) {
  console.log('Old location cleared'); // Expected 404
}
const newData = await dj.get('users/registered/guest1');

2. Script Handling

// Server-side script execution
const script = `javascript:
response = {
  modified: data.value.map(item => item * 2)
};
javascript!`;

const result = await dj.post('data.process', script);

3. Binary Files

// Upload file (Browser)
const fileInput = document.querySelector('input[type="file"]');
await dj.uploadFile('documents/report.pdf', fileInput.files[0]);

// Download image with processing
const imgBlob = await dj.get('photos/sunset.jpg', {
  binary: true,
  width: 800,
  quality: 75
});

4. Real-time Sync

const syncConnector = new Connector.Sync({
  baseURL: 'http://localhost:3000'
});

// Join collaboration session
await syncConnector.joinSession('design-session-12');

// Send real-time updates
syncConnector.send('canvas-update', {
  x: 120,
  y: 45,
  color: '#ff0000'
});

// Receive updates
syncConnector.on('canvas-update', (data) => {
  renderCanvas(data);
});

Advanced Features

Security Configuration

// HMAC Device Auth
const deviceConnector = new Connector({
  baseURL: 'http://localhost:3000',
  hmacSecret: 'device-secret-123'
});

// Secure script execution
const safeScript = await dj.post('scripts/clean-data', {
  script: `// Safe operations only`,
  timeout: 5000,
  memoryLimit: 50
});

API Reference

| Method | Description | |-----------------|-------------------------------------| | .get(key) | Retrieve data/File | | .post(key, value) | Create new entry | | .put(key, value) | Update existing entry | | .move(from, to) | Move data between keys | | .sync() | Real-time operations | | .listKeys(regEx) | list keys |

License

MIT License - See LICENSE for details