@marblejs/middleware-io
TypeScript icon, indicating that this package has built-in type declarations

4.1.0 • Public • Published

Marble.js logo

@marblejs/middleware-io

IO validation middleware for Marble.js for Marble.js.

Installation

$ npm i @marblejs/middleware-io

Requires @marblejs/core to be installed.

Documentation

For the latest updates, documentation, change log, and release information visit docs.marblejs.com and follow @marble_js on Twitter.

Usage

import { r } from '@marblejs/http';
import { requestValidator$, t } from '@marblejs/middleware-io';

const userSchema = t.type({
  id: t.string,
  firstName: t.string,
  lastName: t.string,
  roles: t.array(t.union([
    t.literal('ADMIN'),
    t.literal('GUEST'),
  ])),
});

type User = t.TypeOf<typeof userSchema>;

const effect$ = r.pipe(
  r.matchPath('/'),
  r.matchType('POST'),
  r.useEffect(req$ => req$.pipe(
    requestValidator$({ body: userSchema }),
    // ..
  )));

License: MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @marblejs/middleware-io

Weekly Downloads

83

Version

4.1.0

License

MIT

Unpacked Size

26.2 kB

Total Files

24

Last publish

Collaborators

  • jflakus