UNPKG

jeet-kiit-crud

Version:

A simple CRUD client npm package using API key + Postgres

105 lines (69 loc) โ€ข 2.66 kB
# ๐Ÿ“š CRUD Library --- ## ๐Ÿงฉ `jeet-kiit-crud` โ€” API-Key Protected CRUD Client [![npm](https://img.shields.io/npm/v/jeet-kiit-crud?color=%2300b894&label=npm%20package)](https://www.npmjs.com/package/jeet-kiit-crud) [![License](https://img.shields.io/npm/l/jeet-kiit-crud?color=blue)](LICENSE) [![Build](https://img.shields.io/badge/build-passed-brightgreen)](#) [![Made by Jeet](https://img.shields.io/badge/made%20by-jeet%20das-%23e84393)](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! ---