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
Restless
Express.js api, validations and more.
- Easy to write and read
- Declarative
- 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
asyncHandlerresponseOfsanitizeasStringasNumberasBooleanasObjectasArrayasOptionalasChecked