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 🙏

© 2026 – Pkg Stats / Ryan Hefner

secure-mysql-sdk

v1.3.1

Published

Official MySQL SDK for JavaScript/Node.js - Zero-dependency client optimized for MySQL databases with PHP backend integration

Readme

Secure MySQL SDK

The official MySQL-optimized JavaScript/Node.js SDK for multi-tenant MySQL environments. Built specifically for MySQL + PHP architectures with zero dependencies and shared hosting compatibility.

🚀 Installation

npm install secure-mysql-sdk

📋 Quick Start

const { SecureDbClient } = require('secure-mysql-sdk');

// Initialize client
const client = new SecureDbClient(
  'https://your-api-endpoint.com/api.php',
  'your-api-key',
  { database: 'your-database-name' }
);

// Query data
const users = await client.from('users').select('*');
console.log(users.data);

🏗️ Server Integration

This SDK is designed to work with Secure Database API servers. Whether you're running:

  • Local Development: http://localhost/secure-database-api/backend/public/api.php
  • Production Server: https://your-domain.com/api.php
  • Cloud Deployment: Any hosted Secure Database API instance

The SDK automatically handles authentication, request formatting, and response parsing, making it much easier than direct HTTP calls.

Why Use the SDK vs Direct API Calls?

Zero Dependencies - No external libraries required
Type Safety - Full TypeScript support included
Method Chaining - Fluent, readable query syntax
Auto Authentication - Handles API keys and JWT tokens
Error Handling - Comprehensive error management
Query Builder - No need to manually construct API requests

🔧 Usage

Initialize Client

const { SecureDbClient } = require('secure-mysql-sdk');

const client = new SecureDbClient(baseUrl, apiKey, options);

Parameters:

  • baseUrl (string): Your API endpoint URL
  • apiKey (string): Your API key
  • options (object): Configuration options
    • database (string): Database name
    • projectId (string): Optional project ID
    • timeout (number): Request timeout in milliseconds (default: 30000)

Select Data

// Get all records
const result = await client.from('users').select('*');

// Select specific columns
const result = await client.from('users').select('id, name, email');

// With conditions
const result = await client
  .from('users')
  .select('*')
  .eq('status', 'active')
  .gt('age', 18)
  .limit(10);

// Get single record
const user = await client
  .from('users')
  .select('*')
  .eq('id', 1)
  .single();

Insert Data

const result = await client
  .from('users')
  .insert({
    name: 'John Doe',
    email: '[email protected]',
    age: 30
  });

Update Data

const result = await client
  .from('users')
  .update({ name: 'Jane Doe' })
  .eq('id', 1);

Delete Data

const result = await client
  .from('users')
  .delete()
  .eq('id', 1);

🔍 Query Methods

Filters

.eq('column', value)       // Equal to
.neq('column', value)      // Not equal to
.gt('column', value)       // Greater than
.lt('column', value)       // Less than
.like('column', pattern)   // LIKE pattern matching
.in('column', [values])    // IN array of values

Modifiers

.order('column', true)     // Order by column (true = ASC, false = DESC)
.limit(10)                 // Limit results
.offset(20)                // Offset results

📊 Response Format

All methods return a response object with the following structure:

{
  data: [...],           // Query results or null
  error: {               // Error object or null
    message: "Error description",
    details: {...}       // Additional error details
  },
  status: 200,           // HTTP status code
  statusText: "OK",      // HTTP status text
  count: 5               // Number of records (for select queries)
}

Success Response

{
  data: [
    { id: 1, name: 'John', email: '[email protected]' },
    { id: 2, name: 'Jane', email: '[email protected]' }
  ],
  error: null,
  status: 200,
  statusText: "OK",
  count: 2
}

Error Response

{
  data: null,
  error: {
    message: "Table 'users' not found",
    details: {...}
  },
  status: 404,
  statusText: "Not Found"
}

🌐 Browser Support

The SDK works in both Node.js and modern browsers:

<!-- Browser usage -->
<script src="https://unpkg.com/secure-mysql-sdk"></script>
<script>
  const client = new SecureDbClient(apiUrl, apiKey, options);
</script>

🔒 Error Handling

try {
  const result = await client.from('users').select('*');
  
  if (result.error) {
    console.error('API Error:', result.error.message);
  } else {
    console.log('Data:', result.data);
  }
} catch (error) {
  console.error('Network Error:', error.message);
}

🛠️ Advanced Usage

Raw SQL Queries

const result = await client.sql(
  'SELECT * FROM users WHERE age > ?',
  [18]
);

Database Schema

const schema = await client.getSchema();
console.log('Available tables:', schema.data);

Multiple Databases

const client1 = client.database('database1');
const client2 = client.database('database2');

const users1 = await client1.from('users').select('*');
const users2 = await client2.from('users').select('*');

📝 TypeScript Support

The package includes TypeScript definitions:

import { SecureDbClient, ApiResponse } from 'secure-mysql-sdk';

const client = new SecureDbClient(baseUrl, apiKey, { database: 'mydb' });

const result: ApiResponse = await client
  .from('users')
  .select('*')
  .eq('active', true);

🔧 Configuration Examples

Basic Setup

const client = new SecureDbClient(
  'https://api.example.com/secure-db',
  'sdk_abc123...',
  { database: 'production_db' }
);

With Timeout

const client = new SecureDbClient(
  'https://api.example.com/secure-db',
  'sdk_abc123...',
  { 
    database: 'production_db',
    timeout: 60000  // 60 seconds
  }
);

📄 License

MIT

🤝 Contributing

Issues and pull requests are welcome at the GitHub repository.

📚 Documentation

For more detailed documentation, visit: Full Documentation


Made with ❤️ for developers who need a simple, powerful database SDK