New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

restdatasource

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restdatasource

A simple and flexible datasource library for Javascript with REST support. Features pagination, search, local buffering and navigation (next/prev), inspired by Delphi Datasource simplicity.

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

RestDataSource

A TypeScript library to consume REST APIs in a simple way, with record buffering, page navigation, and full CRUD support.
Perfect when you need to handle pagination, keep a local cache of records, and control navigation between them.

✨ Features

  • 🔄 Automatic pagination (with configurable bufferSize)
  • ⏩ Record navigation (next, prev, goto, first, last)
  • 🔍 Search and filters (search, findBy)
  • 📝 Full CRUD support (insert, update, delete)
  • 🔗 Custom Axios instance support
  • 📊 Utility methods like dump() for debugging

🚀 Installation

npm install restdatasource

📦 Basic Usage

import axios from "axios";
import { RestDataSource } from "restdatasource";

const api = new RestDataSource("http://localhost:3000/users", {
  axios: axios.create({ baseURL: "http://localhost:3000" }),
  bufferSize: 50,
  primaryKey: "id"
});

async function main() {
  await api.load();                // First Load 
  console.log(api.current());      // Show current row
  console.log(await api.next());   // Next
  console.log(await api.prev());   // Previous
  console.log(await api.goto(120)) // Goto to global index 128
}
main();

🔍 Search and Filters

// Pesquisa por nome
await api.findBy("name", "Felipe");

// Pesquisa com múltiplos filtros
await api.search({ status: "active", age: 30 });

📝 CRUD

// Criar
await api.insert({ name: "Novo usuário", email: "teste@mail.com" });

// Atualizar
await api.update(1, { email: "novoemail@mail.com" });

// Deletar
await api.delete(1);

⚙️ Options

PropriedadeTipoPadrãoDescrição
endpointstring-API endpoint (required)
axiosAxiosaxios.create()Custom Axios client
pagenumber1Initial page
bufferSizenumber100Number of records per page (buffer size)
primaryKeystring"id"Primary key field in records

📊 Expected Backend Response

{
  "rows": [ ... ],
  "count": 999
}

FAQs

Package last updated on 26 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts