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

@briohr/nestjs-lib

v0.0.6

Published

Lib for BrioHR app

Downloads

2

Readme

Description

Lib for nestJS projects, developed by the BrioHR Team.

Installation

$ npm install --save @briohr/nestjs-lib

Usage

##I. Paginator

Introduction:

The paginator lib is providing some tools to complete the mongoose-paginate-v2 plugin on nestjs.

It will provide 2 things:

  • A decorator Paginator for the controller to get the query params and format them to match the config.
  • A dto type OptionParamsDto to create the swagger documentation

Config:

The config is currently a constant array and will do the following:

  • format the name following the following convention:
    docs: "data",
    meta: "metadata"
    limit: "perPage",
    page: "currentPage",
    nextPage: "nextPage",
    prevPage: "prevPage",
    totalPages: "totalPages",
    totalDocs: "itemCount",
    pagingCounter: "pagingCounter",
    

Note : data will be returned in data and paginator info in metadata

  • Activate the following options: select, collation, sort, page and limit
  • By default if no value is provided, page will be 1 and limit 100.
  • A maximum for the limit option is also configured at 1000.

Example:

@Get()
public async findAll(@Paginator() options: OptionParamsDto) {
  return this.leavesService.paginateFindAll(options);
}

Setup:

To paginate a collection, you just need to do the following:

  1. Add the plugin mongoosePaginate in the Schema you want to paginate: LeaveSchema.plugin(mongoosePaginate);
  2. You can now use the paginate method in your service: return this.leaveModel.paginate({}, options);
  3. You can now simply add the decorator Paginator in your controller as describe above.

II. Utils

Exception:

Two exceptions are currently available in the lib:

  • GlobalException catches every error and logs them in the std error. You can add simply add in ad global exception in your main.ts file.
  const { httpAdapter } = app.get(HttpAdapterHost);
  app.useGlobalFilters(new GlobalException(httpAdapter));
  • MongoError catches every mongoose error and format them in a nicer output. You can add it globally like the above or add it in the controller
  @UseFilters(MongoExceptionFilter)
  export class LeaveGroupsController {

Pipes:

Some pipes are available for specific input.

  • ObjectIdPipe checks the input is a valid mongoId
  public async findOne(@Param("leaveGroupId", ObjectIdPipe) leaveGroupId: string) {
  • StringNotEmptyPipe checks the string provided is not null and not empty
  @Param("leaveTypeName", StringNotEmptyPipe) leaveTypeName: string,