JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 297
  • Score
    100M100P100Q103038F

Express.js api, validations and more

Package Exports

  • @restless/restless

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@restless/restless) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme


NPM CircleCI License

Restless

Express.js api, validations and more.

  1. Easy to write and read
  2. Declarative
  3. Type safe
import express from 'express'
import { asyncHandler, responseOf, sanitize, asString } from 'restless'

const app = express()
app.get('/add/:a/:b', asyncHandler(
  sanitize({
    a: asNumber,
    b: asNumber
  }),
  ({ a, b }) => responseOf(a + b)
))

Later:

GET /add/1/2 -> 200: 3
GET /add/foo/2 -> 400: { path: 'params.a', expected: 'number' }

Api

  1. asyncHandler
  2. responseOf
  3. sanitize
  4. asString
  5. asNumber
  6. asBoolean
  7. asObject
  8. asArray
  9. asOptional
  10. asChecked