@safen/express
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

safen

Super Fast Object Validator
for Express based on Safen.

Downloads Version License
dependencies Status devDependencies Status
NPM

Install

npm install @safen/express --save

Usage

import * as safen from "@safen/express"
// or
const safen = require("@safen/express")

Basic Usage

const safen = require("@safen/express")
const express = require("express")

const app = express()

// body parser required
app.use(express.urlencoded({ extended: false }))
app.use(express.json())

app.get("/users", safen.query(`{
  q?: string
}`), (req, res) => {
  res.send("show users!")
})

app.post("/users", safen.body(`{
  username: email,
  password: length_between(8,20)
}`), (req, res) => {
  res.send("store users!")
})

app.use(safen.errorHandler())

app.listen()
  • query method use req.query.
  • body method use req.body.

and, You can use params method also.

  • params method use req.query when HTTP method is GET, otherwise use req.params.

Show full API Document

License

MIT

Package Sidebar

Install

npm i @safen/express

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

13.2 kB

Total Files

6

Last publish

Collaborators

  • wan2land