0.1.0 • Published 5 years ago
safen-express v0.1.0
Safen - Express
Node.js Object Validating Middleware on safen.
Install
npm install safen-express --save
Usage
Import,
import * as safen from "safen-middleware"
// or
const safen = require("safen-middleware")
Basic Usage
const safen = require("safen-middleware")
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.listen()
query
method usereq.query
.body
method usereq.body
.
and, You can use params
method also.
params
method usereq.query
when HTTP method isGET
, otherwise usereq.params
.
0.1.0
5 years ago