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

@amsom-habitat/nest-rest

v2.0.0

Published

Lecture REST façon API Platform : pagination, filtres, tri, 404, CRUD sur table Oracle.

Readme

@amsom-habitat/nest-rest

Lecture REST façon API Platform au-dessus d'Oracle : pagination, tri par identifiant, filtres ApiFilter, 404, CRUD générique sur table et lecture du corps des actions. Sans module ni configuration.

const VIEW = view('AHVWS_CALLY_X', { schema: { booleans: ['ACTIF'] } });
const FILTERS: FilterDefinition = {
  idReclamant: 'ID_RECLAMANT',                                // exact
  nom: { column: 'NOM', operator: 'ipartial' },
  actif: { column: 'ACTIF', operator: 'boolean' },
  idModule: { column: 'ID_MODULE', operator: 'in' },          // a,b ou ["a","b"]
  dateFin: { column: 'DATE_FIN', operator: 'exists' },        // ?exists[dateFin]=false
  annee: { column: 'ANNEE', operator: 'range' },              // ?annee[gte]=2020
};

@Get() findAll(@Query() params: Record<string, unknown>, @Pagination() pagination: Pagination) { … }

const query = this.db(VIEW.name);
applyFilters(query, params, FILTERS);
return listPaginated(VIEW, query, pagination);                // ou { sortColumn: 'ID_MODULE' }

return orNotFound(await this.service.findOne(id), `Ressource ${id}`);
@Post('cloturer_sollicitation')
cloturer(@Pec() pec: PecAgent | null, @Body() corps: RequestBody) {
  return this.service.cloturer(exigerPec(pec), {
    idSollicitation: requiredField(corps, 'idSollicitation'),
    motifCloture: optionalField(corps, 'motifCloture', 'TRA'),
  });
}

Comportements à connaître

  • Pagination : limit/offset seulement si itemsPerPage est fourni (le ROWNUM ralentit les vues lourdes). Une valeur invalide (0, -1, abc) est ignorée comme en v1 (pagination_enabled: false).
  • Paramètre répété (?x=a&x=b) : la dernière valeur gagne, comme PHP.
  • Filtres : sémantique d'API Platform 4 (SearchFilter, BooleanFilter, ExistsFilter, RangeFilter) et des filtres maison v1 (InFilter, ArrayIncludesFilter). ?x= (vide) filtre sur '', donc 0 ligne sous Oracle ; avec integer: true, une valeur non entière est ignorée. Les colonnes interpolées dans du SQL brut doivent être des identifiants Oracle (sinon erreur).
  • orNotFound : 404 sur null, undefined et 0 (aucune ligne touchée par un DELETE).
  • CrudService : relit chaque écriture via findOne ; PATCH partiel, sans UPDATE si aucun champ connu ; POST sans sequence → 500 explicite ; booléen non interprétable ou timestamp invalide → 400. integerId: true caste l'identifiant comme API Platform (abc → 0 → 404).
  • Corps d'une action : reçu brut, null compris (RequestBody, que le ValidationPipe ne touche pas), pour pouvoir servir tel quel à un mail ou un document. La conversion vers Oracle se fait au bind (nest-oracle). requiredField : clé absente → MissingFieldError (400), null accepté. optionalField : absent ou null → défaut. isEmpty suit empty() de PHP, le contrat des fronts : 0, '0', '', [], {} sont vides. Les clés héritées du prototype sont ignorées.

Migration 1.x → 2.0

| 1.x | 2.0 | | --- | --- | | trierEtPaginer(q, p, 'COL') | sortAndPaginate(q, p, { sortColumn: 'COL' }) | | VUE.lignes(await trierEtPaginer(q, p)) | listPaginated(VIEW, q, p) | | ouIntrouvable(v, l) | orNotFound(v, l) | | parseFiltreBooleen | parseBooleanFilter (+ applyBoolean) | | appliquerRecherche(q, c, v, 'ipartial') | applySearch(q, c, v, { strategy: 'ipartial' }) | | appliquerIn / appliquerNotIn / appliquerExists | applyIn / applyNotIn / applyExists | | appliquerArrayIncludes / appliquerRange / extraireBornes / Bornes | applyArrayIncludes / applyRange / extractBounds / RangeBounds | | StrategieRecherche | SearchStrategy | | appliquerSimpleSearch | supprimé | | ServiceCrud | CrudService | | CrudTable { vue, champs, dates: ['COL'] } | CrudTableDefinition { table, fields, dates: { COL: ORACLE_DATE_FORMAT } } |