yourname-formpilot-crud
v1.0.0
Published
A lightweight CRUD library for the FormPilot assignment
Readme
yourname-formpilot-crud
A lightweight CRUD library for interacting with the CRUD API.
Installation
npm install shivamlahoty-formpilots-crud
Configuration
Create a .env file in your project root with:
CRUD_API_URL=http://your-api-url.com CRUD_API_KEY=your-unique-api-key
Usage
const Crublibrary = require('yourname-formpilot-crud');
// Create an item const createResponse = await Crublibrary.create({ value: 0.5, txHash: "32424" }); // Output: { id: "32872", status: "created successfully" }
// Get an item const getResponse = await Crublibrary.get("32872"); // Output: { value: 0.5, txHash: "0x..." }
// Update an item const updateResponse = await Crublibrary.update("32872", { value: 0.9 }); // Output: { status: "updated successfully" }
// Delete an item const deleteResponse = await Crublibrary.delete("32872"); // Output: { status: "deleted successfully" }
Error Handling
The library will throw an error if:
- API key or URL is missing
- Request limit is exceeded
- Invalid data is provided
- Item ID doesn't exist
