JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 25
  • Score
    100M100P100Q61473F
  • License MIT

RawLib β€” RawQL engine, adapters and validation module

Package Exports

  • raw_lib
  • raw_lib/dist/index.cjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (raw_lib) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

🧠 raw_lib β€” A Modular Query & Validation Engine for Node.js

raw_lib is a modular, flexible, and database-independent library that enables structured query execution (RawQL) and schema-based validation (RawVal) using a Clean Architecture mindset.

It’s designed to empower backend developers to rapidly implement standardized APIs, reduce boilerplate, and let frontends query exactly what they need β€” securely and scalably.


πŸ”₯ Why raw_lib?

  • βœ… Database Independent (MongoDB, SQL, Redis, etc.)
  • πŸš€ Structured Query Engine: Run create, read, update, delete, list, count, and aggregation through unified RawQlRequest
  • πŸ”’ Integrated Validation Engine (RawVal)
  • πŸ”Œ Pluggable Adapters & Middleware
  • ♻️ Reusable in CLI, API, or Microservices
  • 🧰 Written in TypeScript

πŸ“¦ Installation

npm install raw_lib

πŸ“ Structure

  • rawql/ β€” Core query execution engine
  • rawval/ β€” Validation engine (optional)
  • adapters/ β€” Adapter interfaces & implementations (MongoDB etc.)
  • types/ β€” Cleanly defined types for request & response

πŸ“˜ RawQl: Query Engine

πŸ”„ Supported Operations

export type RawQlOperation =
  | "list"
  | "get"
  | "create"
  | "update"
  | "delete"
  | "count"
  | "aggregate";

πŸ“₯ RawQlRequest

const request: RawQlRequest = {
  type: "list",
  entity: "User",
  filter: { field: "role", op: "eq", value: "admin" },
  options: {
    page: 1,
    limit: 10,
    sort: [{ field: "createdAt", direction: "desc" }],
    populate: ["profile"], // Mongoose adapter only
  },
};

πŸ“€ RawQlResponse

{
  status: true,
  message: "Fetched User list successfully",
  data: {
    type: "paginated",
    items: [...],
    totalItems: 10,
    currentPage: 1,
    totalPages: 1
  }
}

🧩 MongoAdapter (example)

import { MongoAdapter } from "raw_lib";
import mongoose from "mongoose";

const adapter = new MongoAdapter("mongodb://localhost:27017/mydb");

adapter.registerModel("User", userSchema);
adapter.registerModel("Todo", todoSchema);

Then use it in the engine:

import { RawQlEngine } from "raw_lib";
const engine = new RawQlEngine(adapter);

const response = await engine.execute({
  type: "get",
  entity: "User",
  filter: { field: "username", op: "eq", value: "raunak" },
});

πŸ›‘οΈ Validation (RawVal Engine)

const validator = new RawValEngine();

validator.register("User", {
  create: {
    username: z.string().min(3),
    email: z.string().email(),
    password: z.string().min(6),
  },
});

βš™οΈ Middleware Support

engine.use(async (req) => {
  // Example: Inject userId
  req.data.userId = "xyz123";
});

πŸ“¦ Works Seamlessly With:

βœ… raw_cli (Node CLI generator)
βœ… Clean Architecture setups
βœ… Any framework using Express, Fastify, NestJS, etc.


πŸš€ Example POST /users/list API

app.post("/users/list", async (req, res) => {
  const response = await engine.execute(req.body);
  res.json(response);
});

🧠 Example Use Cases

  • Replace REST CRUD APIs with structured queries
  • Pass only one generic controller per entity (/users, /todos)
  • Decouple frontend from backend changes
  • Auto-generate frontend SDKs (future)
  • Add permissions/validation with middlewares

🏁 Roadmap

  • Mongoose Adapter
  • Zod-based Validation Engine
  • Aggregation Pipeline support
  • Populate support (Mongoose)
  • Redis Adapter
  • SQL Adapter
  • CLI Integration (raw_cli)
  • Socket Adapter (idea stage)

✍️ Author

Made with ❀️ by Raunak Pandey

GitHub: github.com/raunak-dows17


πŸ“„ License

MIT License

Use it. Improve it. Fork it. Break it. We’re just getting started.