jeet-kiit-crud
Version:
A simple CRUD client npm package using API key + Postgres
105 lines (69 loc) โข 2.66 kB
Markdown
# ๐ CRUD Library
## ๐งฉ `jeet-kiit-crud` โ API-Key Protected CRUD Client
[](https://www.npmjs.com/package/jeet-kiit-crud)
[](LICENSE)
[](#)
[](https://github.com/JeetDas5)
> ๐ A secure, API-key-based CRUD client for use with FormPilot or custom backend APIs.
> Built with TypeScript, Axios, and fully Postgres-ready.
### ๐ฆ Install
```bash
npm install jeet-kiit-crud
```
### โ๏ธ Setup
```ts
import { CrudLibrary } from "jeet-kiit-crud";
// You should retrieve these from sessionStorage, login response, or env
const crud = CrudLibrary({
apiKey: "your-api-key-here",
apiUrl: "https://your-crud-domain.com/api",
API_TODO_URL: "your-todo-domain"
});
```
### ๐ Available Methods
| Method | Description |
|---------------------|---------------------------------------|
| `create(data)` | Create a new record |
| `get(id)` | Fetch a single record |
| `getAll()` | Fetch all records |
| `update(id, data)` | Update a record |
| `remove(id)` | Delete a record |
| `getCredits()` | Check current credit usage |
| `getCreditLimit()` | Check current credit limit |
| `recharge()` | Recharge credits via backend approval |
### ๐ง Example
```ts
const res = await crud.create({
value: "Learn NPM packages!",
txHash: "0x123abc",
});
console.log(res.id); // -> New record ID
const all = await crud.getAll();
console.log(all);
```
### ๐ Authentication
All requests include the `x-api-key` header.
Each user has a limited number of credits (default: 4), and they can call `recharge()` once for an extra 4 credits.
### ๐งช Use Cases
- โก Intern assignment projects
- ๐งพ Billing or credit-tracked APIs
- ๐ Secure public access to APIs
- ๐งฑ Shared API client across frontend apps
### ๐จโ๐ป Author
Made with ๐ by [**Jeet Das**](https://github.com/JeetDas5)
### ๐ License
This project is licensed under the [MIT License](LICENSE).
### โญ Like it?
Give it a โญ on [GitHub](https://github.com/JeetDas5)
And tag me if you use it in your own project!