sheetsandbox
v1.0.0
Published
Simple Node.js SDK for SheetSandbox - Turn Google Sheets into your MVP database. Easy to understand, ready to extend.
Maintainers
Readme
SheetSandbox SDK for Node.js
A simple and easy-to-understand Node.js SDK for SheetSandbox - Turn Google Sheets into your production-ready database.
🎯 Features
- ✅ Simple & Clean - Easy to understand code without complex parts
- ✅ Basic CRUD Operations - Get, GetById, and Post
- ✅ Promise-based - Modern async/await support
- ✅ Lightweight - Minimal dependencies
- ✅ Ready to Extend - Clean architecture for future enhancements
📦 Installation
npm install sheetsandbox🚀 Quick Start
import SheetSandbox from 'sheetsandbox';
// Initialize the client
const client = new SheetSandbox('your-api-token');
// Users -> SheetName
// Create a record
const result = await client.post('Users', {
name: 'John Doe',
email: '[email protected]'
});
// Get all records
const users = await client.get('Users');
// Get a specific record
const user = await client.getById('Users', 1);📖 API Reference
Constructor
const client = new SheetSandbox(token, options);Parameters:
token(string, required) - Your SheetSandbox API tokenoptions(object, optional)baseURL(string) - API base URL (default: 'http://localhost:3001/api')timeout(number) - Request timeout in ms (default: 30000)
Methods
get(tableName)
Get all records from a table.
const result = await client.get('Users');
if (result.success) {
console.log(result.data); // Array of records
}Returns: Promise<Object>
success(boolean) - Operation statusdata(array) - Array of recordsstatus(string) - 'success' or 'error'error(string) - Error message (if failed)
getById(tableName, id)
Get a specific record by ID.
const result = await client.getById('Users', 1);
if (result.success) {
console.log(result.data); // Single record
}Parameters:
tableName(string) - Name of the tableid(number|string) - Record ID (1-based index)
Returns: Promise<Object>
success(boolean) - Operation statusdata(object) - Record datastatus(string) - 'success' or 'error'error(string) - Error message (if failed)
post(tableName, data)
Create a new record.
const result = await client.post('Users', {
name: 'John Doe',
email: '[email protected]'
});
if (result.success) {
console.log('Record created!');
}Parameters:
tableName(string) - Name of the tabledata(object) - Record data to create
Returns: Promise<Object>
success(boolean) - Operation statusdata(object) - Created record datastatus(string) - 'success' or 'error'error(string) - Error message (if failed)
setToken(newToken)
Update the API token.
client.setToken('new-api-token');setBaseURL(newBaseURL)
Update the base URL.
client.setBaseURL('https://api.sheetsandbox.com');getConfig()
Get current configuration.
const config = client.getConfig();
console.log(config);
// { baseURL: '...', timeout: 30000, hasToken: true }💡 Examples
Waitlist Signup
import SheetSandbox from 'sheetsandbox';
const client = new SheetSandbox('your-api-token');
async function addToWaitlist(email, name) {
const result = await client.post('Waitlist', {
email: email,
name: name,
timestamp: new Date().toISOString()
});
if (result.success) {
console.log('✅ Added to waitlist!');
} else {
console.log('❌ Error:', result.error);
}
}
addToWaitlist('[email protected]', 'Jane Doe');Feedback Form
async function submitFeedback(feedback) {
const result = await client.post('Feedback', {
message: feedback.message,
rating: feedback.rating,
email: feedback.email,
submitted_at: new Date().toISOString()
});
return result.success;
}Get User List
async function getUserList() {
const result = await client.get('Users');
if (result.success) {
result.data.forEach(user => {
console.log(`${user.name} - ${user.email}`);
});
}
}🔧 Error Handling
All methods return a consistent response format:
const result = await client.get('Users');
if (result.success) {
// Operation succeeded
console.log(result.data);
} else {
// Operation failed
console.log(result.error);
}🛣️ Roadmap
This is a simplified version designed to be easy to understand and extend. Future enhancements may include:
- [ ] Batch operations (create multiple records at once)
- [ ] Advanced filtering and sorting
- [ ] Duplicate prevention
- [ ] Update and delete operations
- [ ] Pagination support
- [ ] Retry logic
- [ ] TypeScript support
📝 License
MIT
🔗 Links
💬 Support
For issues and questions, please visit our GitHub Issues.
