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

express-parse-query-sequelize

v0.0.8

Published

[Express.js](https://expressjs.com) middleware used to parse http query to [Sequelize.js](https://sequelize.org).

Downloads

22

Readme

Express.js Parse Query To Sequelize.js

Express.js middleware used to parse http query to Sequelize.js.

npm package version number Actions Status License

It uses npm, TypeScript compiler, Jest, ESLint, Prettier, husky, pinst, commitlint. The production files include ES Modules and TypeScript declaration files.

Installation

npm install express-parse-query-sequelize

Usage

Server

import parserQueryMiddleware from "express-parse-query-sequelize";

app.use(parserQueryMiddleware);
// req.queryParsed contains a content of req.query parsed to sequelize

app.get("/user", (req: Request, res: Response) => {
  UserModel.findAndCountAll(req.queryParsed)
    .then((users) => {
      res.status(200).json(users);
    })
    .catch((err: Error) => res.status(500).json(err));
});

Where

// Where name equals "john" and email equals "[email protected]"
?eq=name:john,email:[email protected]

// Where name is not equals "john"
?!eq=name:john

// Where id greater than "1"
?gt=id:1

// Where id less than "10"
?lt=id:10

// Where name like "%john%doe%"
?like=name:*john*doe*

// Where id equals "1" and name like "john"
?and[eq]=id:1&and[like]=name:john

// Where id equals "1" or name like "john"
?or[eq]=id:1&and[like]=name:john

Sorting

// Sort by id in ascending order
?sort_by=id:asc

// Sort by id in descending order
?sort_by=id:desc

// Sort by id in descending order and name in ascending order
?sort_by=id:desc,name:asc

Grouping

// Group by
?group_by=id,name

Fields

?fields=id,name,email

Operators

gt -----------> greater than
gte ----------> greater or equals than
lt -----------> less than
lte ----------> less than or equals
eq -----------> equals
!eq ----------> not equals
like ---------> like
!like --------> not like
between ------> between
!between -----> not between
in -----------> in
!in ----------> not in
and[op] ------> and operator
or[op] -------> or operator

Development

Install dependencies with npm

npm i

Note: make necessary changes in package.json the version of the package.

Test

Test your code with Jest framework:

npm run test

Note: this package uses husky, pinst and commitlint to automatically execute test and lint commit message before every commit.

Build

Build production (distribution) files in your dist folder:

npm run build

It generates ES Modules (in dist/ folder), as well as TypeScript declaration files (in dist/types folder).

publish

Publish the library on the npm:

npm run publishnpm