pandadb-node
v0.1.2
Published
Official Node.js SDK for PandaDB - A high-performance, API-first database service
Maintainers
Readme
PandaDB Node.js SDK - Development Guide
This guide explains how to build and publish the PandaDB Node.js SDK.
Development Setup
- Clone the repository:
git clone <your-repo-url>
cd sdk- Install dependencies:
npm installBuilding the SDK
- Run the build command:
npm run buildThis will:
- Clean the dist directory
- Compile TypeScript to JavaScript
- Generate type declaration files
- Create source maps
The build output will be in the dist directory:
dist/*.js- Compiled JavaScript filesdist/*.d.ts- TypeScript declaration filesdist/*.map- Source maps
Testing
- Run tests:
npm test- Run linting:
npm run lint- Format code:
npm run formatPublishing to npm
- Login to npm:
npm login- Update version (choose one):
npm version patch # For bug fixes (0.0.x)
npm version minor # For new features (0.x.0)
npm version major # For breaking changes (x.0.0)- Build and publish:
npm run build
npm publishThe package will be published as @pandadb/node.
Development Workflow
- Make changes to files in
src/ - Run tests:
npm test - Run linting:
npm run lint - Build:
npm run build - Test the built package:
# In another project npm install ../path/to/sdk
Package Structure
sdk/
├── src/
│ ├── client.ts # Main SDK implementation
│ ├── types.ts # TypeScript type definitions
│ ├── errors.ts # Error handling classes
│ └── index.ts # Public API exports
├── package.json # Package configuration
└── tsconfig.json # TypeScript configurationLocal Testing
To test the SDK locally in another project:
- In the SDK directory:
npm run build
npm pack- In your test project:
npm install ../path/to/pandadb-node-0.1.0.tgzContinuous Integration
Before publishing:
- Ensure all tests pass
- Check linting
- Verify the build works
- Test the package locally
Publishing Checklist
- [ ] Update version in package.json
- [ ] Run tests
- [ ] Run linting
- [ ] Build the package
- [ ] Test the built package locally
- [ ] Update README if needed
- [ ] Commit all changes
- [ ] Create git tag
- [ ] Push to repository
- [ ] Publish to npm
Example Usage
After publishing, users can install the package:
npm install @pandadb/nodeAnd use it in their code:
import { PandaDB } from '@pandadb/node';
const client = new PandaDB({
token: 'YOUR_AUTH_TOKEN'
});
// Execute a query
const result = await client.query(
'db_123abc',
'SELECT * FROM users WHERE age > ?',
[18]
);
// Use real-time subscriptions
const unsubscribe = client.subscribe(
'db_123abc',
'users',
{
onCreate: (user) => console.log('New user:', user),
onUpdate: (user) => console.log('Updated user:', user),
onDelete: (id) => console.log('Deleted user:', id)
}
);
// Clean up when done
unsubscribe();Troubleshooting
Common issues:
Build errors:
- Run
npm installto ensure all dependencies are installed - Check TypeScript errors in your IDE
- Run
npm run lintto find issues
- Run
Publishing errors:
- Ensure you're logged in to npm:
npm login - Check if the package name is available
- Verify you have publish access to the @pandadb organization
- Ensure you're logged in to npm:
Type errors:
- Check that all types are properly exported in index.ts
- Verify tsconfig.json settings
- Ensure declaration files are generated
Support
For any issues:
- Check the troubleshooting guide
- Run tests and linting
- Contact the PandaDB team
