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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sonicfury/spider-query-builder

v3.3.0

Published

Offers typing and query params building for API Platform

Downloads

57

Readme

           _     _                                       _           _ _     _
          (_)   | |                                     | |         (_| |   | |
 ___ _ __  _  __| | ___ _ __  __ _ _   _  ___ _ __ _   _| |__  _   _ _| | __| | ___ _ __
/ __| '_ \| |/ _` |/ _ | '__ / _` | | | |/ _ | '__| | | | '_ \| | | | | |/ _` |/ _ | '__|
\__ | |_) | | (_| |  __| |  | (_| | |_| |  __| |  | |_| | |_) | |_| | | | (_| |  __| |
|___| .__/|_|\__,_|\___|_|   \__, |\__,_|\___|_|   \__, |_.__/ \__,_|_|_|\__,_|\___|_|
    | |                         | |                 __/
    |_|                         |_|                |___/

GitHub Release GitHub License test publish

Installation

$ npm i @sonicfury/spider-query-builder

What it does

This typescript library is designed to help you interact between your front end app and your backend based on API Platform. It can help you build your query from a filters form with typing etc.

License

This project is under AGPL 3 License

See license

How to

See docs

Example

Say you have a DomainService (domain.service.ts file) with the something like:

class DomainService extends AbstractService{
    
    getDomain(query: string): Observable<HttpResponse<Domain[]>> {
        const url = `${this.baseUrl}/domain?${query}`;

        return this.http.get<Domain[]>(url);
    }
}

API Platform has specific semantics for the built-in filters.

With this library, you have to build SpiderParams for each filter, like:

import {SpdrQueryBuilder} from "./SpdrQueryBuilder";

const qb = new SpdrQueryBuilder(); // initialize the builder

qb
    .exists('username', true) // wether the property 'username' exists
    .search('firstname', ['john']) // search for a 'john' firstname
    .search('lastname', ['doe']) // search for a 'doe' lastname
    .range('rank', 1, 200); // search for a result with rank between 1 and 200


this.domainService.getDomain(qb.query)
    .subscribe(
        // ...
    )

qb.query will be formatted as exists[username]=true&firstname=john&lastname=doe&rank[between]=1..200;

Issues

Feel free to submit an issue if you find something wrong or if you feel some important feature is missing. Be sure to note the version you're using, and provide minimum context and information (as if you were on SO).

Contributing

You're welcome to contribute if you want. Just be sure to check the guidelines