0.1.1 • Published 5 years ago

@safen/express v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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