1.0.0 • Published 4 years ago

pickrr v1.0.0

Weekly downloads
319
License
LGPL-3.0
Repository
github
Last release
4 years ago

Pickrr

CircleCI npm Codecov

Contracts in Typescript done right.

Goal

To have a simple contract in typescript that doesn't need an accompanying interface. i.e. The contract itself is the interface.

Installation

npm i --save pickrr

Usage

import {pick, number, string} from 'pickrr'

// Let's say req.body = {id: '1', name: 'John Doe'}

const data = pick({
  id: number,
  name: string,
}, req.body);

// data now has a signature of {id: number; name: string}
// and a value of {id: 1, name: 'John Doe'}

You can even pass multiple objects

import {pick, number, string, date} from 'pickrr'

const data = pick({
  id: number,
  name: string,
  birthdate: date,
}, req.params, req.body);

// data now has the same signature as the contract itself.

The trick? Take a look at src/index.ts.

1.0.0

4 years ago

0.5.2

6 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago