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

@perigress/perigress

v0.3.0

Published

Contract testing + Data Generation

Downloads

255

Readme

Perigress

A medium for contract based development.

Data maintenance, contract testing and data generation without boilerplate using a series of either joi validators(.spec.js), JSON Schema(.spec.schema.js), or example JSON(.spec.json) files to represent the structure of the API URLs(which you are probably already writing).

The ultimate goal of this library is to generate fully functional and tested backends, mocks, seeds and migrations from nothing more than a set of schema.

1. Setup the directory layout

Only a single file is required to generate a test api, and that's the schema of the object you want to generate. That might be as simple as:

mkdir verifiers
mkdir verifiers/api
cp ../joi_user_definition.js verifiers/api/user.spec.js # OR
# cp ../json-schema_user.js verifiers/api/user.spec.schema.js

More complex options are described in the detailed setup document.

2. Use the mock in testing

You can launch the mock on the command line:

# use ./node_modules/perigress/bin/peri if you don't have a global `peri`
peri serve ./verifiers --port 8080
#in another terminal:
open "http://localhost:8080/api/user/list"

You can also launch the server within your code:

const { API } = require('@perigress/perigress');
const Mongonian = require('@perigress/mongonian');

const api = new API({
    subpath : 'verifiers',
    dir: __dirname
}, new Mongonian());
api.attach(expressInstance);

3. Generate data definitions

You can generate data definitions(SQL, Data Model) based on your endpoint contract.

4. Generate DB seed files

You can generate consistent fake data to load into your database without having to be paranoid about sanitizing the dev DB (or having to update seed scripts by hand every single time the DB structure is altered).

5. Generate migrations

Finally, because you can compute the difference between schema, you can also generate migrations for sets of changes of your data definitions.

6. Documentation

At any time the current spec is available at /spec with it's corresponding data at /openapi.json.

Roadmap

  • [x] - list output
  • [x] - primary key support
  • [x] - audit columns
  • [x] - edit support (ephemeral)
  • [x] - example json support
  • [x] - url mapping
  • [x] - seed scripts
  • [x] - documentation via OpenAPI
  • [x] - error output
  • [x] - selector support query filter documents
  • [x] - foreign key support
  • [x] - document assembly
  • [x] - generate + persist requested filter values
  • [x] - internal requests
  • [x] - option to include saved objects in listing
  • [x] - verbose mode
  • [x] - save endpoint with symmetric object disassembly
  • [x] - external express instances in mock
  • [x] - pluggable transports
  • [x] - Mongoish output format
  • [x] - expose sift for extension
  • [x] - passable page config
  • [ ] - query params passed to subqueries
  • [ ] - lifecycle hooks
  • [ ] - validator assembly
  • [ ] - db test suites
  • [ ] - better error handling
  • [ ] - better documentation
  • [ ] - deep object support (allow subobjects and arrays in schema)
  • [ ] - mongosh + mongojs support
  • [ ] - yup support
  • [ ] - Resty output format (json/form/xml)
  • [ ] - prisma support
  • [ ] - mongoose support
  • [ ] - persistent queries (returns for subsequent pages, without needing params)
  • [ ] - api generation

Testing

    mocha
    #or
    ./node_modules/mocha/bin/mocha