npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kadirgun/lucid-bravo

v0.3.0

Published

A powerful, fluent query builder for AdonisJS Lucid to handle filtering, sorting and pagination in a single flow

Downloads

2,900

Readme

Lucid Bravo

Lucid Bravo is a fluent query builder for AdonisJS Lucid models. It helps you keep filtering, sorting, relation preloading, and pagination in one place instead of spreading that logic across controllers.

Installation

npm install @kadirgun/lucid-bravo

Configure

Run the package configure command once in your AdonisJS app:

node ace configure @kadirgun/lucid-bravo

This registers the package command so you can generate new Bravo classes with the scaffold command.

Generate a Bravo class

node ace make:bravo Post

The command creates a file like app/bravos/post_bravo.ts with a ready-to-edit class that extends LucidBravo.

Basic usage

Create a Bravo class for each model and define the allowed sort fields, preload relations, and model-specific filters. The generated scaffold already includes the base-class import, so the example below shows only the parts you normally customize.

type ModelType = typeof Post

export default class PostBravo extends LucidBravo<ModelType> {
  protected model = Post
  protected defaultLimit = 10

  protected override getSortable(): LucidBravoAttributes<ModelType>[] {
    return ['id', 'title']
  }

  protected override getAllowedIncludes(): LucidBravoRelations<Post>[] {
    return ['labels']
  }

  protected async title(value: string) {
    this.$query.where('title', 'like', `%${value}%`)
  }
}

Use the class in a controller with bravoValidator to validate the common query params before passing them to Bravo:

import type { HttpContext } from '@adonisjs/core/http'
import Post from '#models/post'
import PostBravo from '#bravos/post_bravo'
import { bravoValidator } from '@kadirgun/lucid-bravo/validators'

export default class PostController {
  public async index({ request }: HttpContext) {
    const params = await request.validateUsing(bravoValidator)

    return PostBravo.build(params).paginate()
  }
}

You can create a Bravo instance in a few different ways, depending on whether you already have a Lucid query builder or want Bravo to create one from the model declared in the subclass:

const bravoA = new PostBravo({
  limit: 20,
})

const bravoB = new PostBravo(
  {
    limit: 20,
  },
  Post.query()
)

const bravoC = PostBravo.build(
  {
    limit: 20,
  },
  Post.query()
)

// default query and params
const bravoD = PostBravo.build()
const bravoE = new PostBravo()

Query params

Lucid Bravo understands these params out of the box:

  • sort.field and sort.order
  • limit
  • page
  • include
  • any custom filter key that matches a camelCase method on your Bravo class

For example, first_name maps to a firstName() method.

Notes

  • LucidBravo expects to run inside an active HTTP context.
  • Only relations returned by getAllowedIncludes() are preloaded.
  • For the common query shape, you can reuse bravoValidator from @kadirgun/lucid-bravo/validators.
  • If you also need model-specific filters, add a separate Vine schema in your app and merge the validated values before creating the Bravo instance.

License

MIT