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
Use it. Improve it. Fork it. Break it. Weβre just getting started.