quick-deployer-sdk
v1.0.0
Published
A TypeScript SDK for the QuickDeployer API, supporting frontend and backend applications.
Maintainers
Readme
Node QuickDeployer TypeScript SDK
The QuickDeployer TypeScript SDK enables developers to interact with the QuickDeployer API in both Node.js (backend) and browser (frontend) environments. It provides a type-safe interface for managing projects and servers, with robust error handling and modern JavaScript features.
Features
- Manage projects (list, get, create, update, delete).
- Manage servers within projects (list, get, create, update, delete, check status).
- TypeScript support for type safety and IDE autocompletion.
- Compatible with Node.js and browser environments.
- Unit tests with Jest for reliability.
Requirements
- Node.js >= 18.0.0 (for native
fetchsupport) - TypeScript >= 5.4.5
- A QuickDeployer API key
Installation
Install the SDK via npm:
npm install node-quick-deployer-sdkIf the SDK is not published, clone the repository and install locally:
git clone https://github.com/niravsutariya/node-quick-deployer-sdk.git
cd node-quick-deployer-sdk
npm install
npm run buildUsage
Initializing the Client
import { Client } from 'node-quick-deployer-sdk';
const apiKey = 'your-api-token';
const client = new Client(apiKey, { baseUrl: 'https://api.quickdeployer.com/api' });Managing Projects
List Projects
const projects = await client.projects().list();
console.log(projects); // [{ id: 'project-123', name: 'Test Project' }, ...]Get a Project
const project = await client.projects().get('project-123');
console.log(project.name); // Test ProjectCreate a Project
const newProject = await client.projects().create({ name: 'New Project' });
console.log(newProject.id); // project-456Update a Project
const updatedProject = await client.projects().update('project-123', { name: 'Updated Project' });
console.log(updatedProject.name); // Updated ProjectDelete a Project
await client.projects().delete('project-123');
console.log('Project deleted');Managing Servers
List Servers
const servers = await client.servers('project-123').list();
console.log(servers); // [{ id: 'server-456', name: 'Test Server' }, ...]Get a Server
const server = await client.servers('project-123').get('server-456');
console.log(server.name); // Test ServerCreate a Server
const newServer = await client.servers('project-123').create({ name: 'New Server', type: 'web' });
console.log(newServer.id); // server-789Update a Server
const updatedServer = await client.servers('project-123').update('server-456', { name: 'Updated Server' });
console.log(updatedServer.name); // Updated ServerDelete a Server
await client.servers('project-123').delete('server-456');
console.log('Server deleted');Check Server Status
const status = await client.servers('project-123').checkStatus('server-456');
console.log(status.status); // onlineError Handling
Use try-catch for API errors:
try {
const projects = await client.projects().list();
} catch (error) {
console.error('Error:', error.message);
}Configuration
- API Key: Obtain from the QuickDeployer dashboard.
- Base URL: Defaults to
https://staging.quickdeployer.com/api. Override viaClientoptions.
Building for Frontend
For browser usage, bundle the SDK with a module bundler (e.g., Webpack, Vite):
npm run buildEnsure your bundler targets ES Modules and includes fetch (available in modern browsers).
Testing
Run unit tests with Jest:
npm testTests are located in the tests/ directory and cover Client, ProjectResource, and ServerResource.
Contributing
- Fork the repository.
- Create a feature branch (
git checkout -b feature/your-feature). - Commit changes (`git commit -m "Add feature"').
- Push to the branch (
git push origin feature/your-feature). - Open a pull request.
Include tests and follow TypeScript/ESLint coding standards.
License
MIT License. See LICENSE for details.
Support
Open issues on GitHub or contact [email protected].
