Welcome to the Clovve Works infrastructure. This guide moves beyond the basics, focusing on secure environment bootstrapping and event-driven architecture. 🚀
1. Prerequisites
Ensure you have Node.js 18+ and a project repository ready. We assume you’re using .env files for secret management—never hardcode credentials.
2. Installation
Install the core SDK and the local bridge for real-time debugging:
Bash
npm install @clovve/core-sdk @clovve/bridge --save
npm install @clovve/core-sdk @clovve/bridge --save
npm install @clovve/core-sdk @clovve/bridge --save
3. Authentication & Configuration
Initialize your workspace provider. We recommend centralizing this in a clovve.config.js or your main entry file (e.g., index.js):
JavaScript
import { Clovve } from '@clovve/core-sdk';
const clovve = new Clovve({
apiKey: process.env.CLOVVE_API_KEY,
environment: process.env.NODE_ENV === 'production' ? 'prod' : 'dev',
timeout: 5000
});import { Clovve } from '@clovve/core-sdk';
const clovve = new Clovve({
apiKey: process.env.CLOVVE_API_KEY,
environment: process.env.NODE_ENV === 'production' ? 'prod' : 'dev',
timeout: 5000
});import { Clovve } from '@clovve/core-sdk';
const clovve = new Clovve({
apiKey: process.env.CLOVVE_API_KEY,
environment: process.env.NODE_ENV === 'production' ? 'prod' : 'dev',
timeout: 5000
});4. Handling Webhooks & Events
Once authenticated, you need to set up your listener to process incoming events from your Shopify or custom storefronts:
JavaScript
clovve.events.on('order.created', async (payload) => {
try {
const { orderId, customerData } = payload;
await processOrder(orderId);
} catch (err) {
console.error('Failed to sync event:', err.message);
}
});
clovve.events.on('order.created', async (payload) => {
try {
const { orderId, customerData } = payload;
await processOrder(orderId);
} catch (err) {
console.error('Failed to sync event:', err.message);
}
});
clovve.events.on('order.created', async (payload) => {
try {
const { orderId, customerData } = payload;
await processOrder(orderId);
} catch (err) {
console.error('Failed to sync event:', err.message);
}
});5. Validate Your Handshake
Verify that your local environment is talking to our infrastructure:
Bash
npx clovve-cli ping --env=dev
npx clovve-cli ping --env=dev
npx clovve-cli ping --env=dev
Expected: [200] Connection established: Workspace ID: [your_id]