express-response-formatter:格式化 Express 响应的更好方法

时间:2021-05-31 10:43:19
【文件属性】:
文件名称:express-response-formatter:格式化 Express 响应的更好方法
文件大小:618KB
文件格式:ZIP
更新时间:2021-05-31 10:43:19
express-middleware json-response api-response response-formatter TypeScript 快速响应格式化程序 格式化 Express 响应的更好方法 这个怎么运作 您可以使用具有可读名称的响应,例如res.formatter.ok表示 200 ok 或res.formatter.badRequest表示 400 错误请求。 它将以success和error两种方式格式化您的响应。 如果响应为2xx, 3xx在对象键data下返回响应。 如果响应为4xx, 5xx在 object key error下返回响应。 您可以将元数据作为第二个参数传递,它会出现在meta对象键下。 安装 npm install express-response-formatter --save 快速开始 响应 200 Ok。 import app from 'express' import { responseEnhancer } from 'express-response-forma
【文件预览】:
express-response-formatter-master
----.travis.yml(282B)
----usage.gif(1000KB)
----example()
--------index.js(1KB)
--------package.json(231B)
--------yarn.lock(15KB)
----package.json(1013B)
----.eslintrc.json(422B)
----test()
--------index.test.ts(2KB)
----.prettierrc(69B)
----jest.config.js(69B)
----src()
--------methods.ts(2KB)
--------index.ts(1KB)
----.npmignore(109B)
----tsconfig.json(6KB)
----LICENSE.md(1KB)
----.gitignore(1008B)
----CHANGELOG.md(2KB)
----README.md(4KB)
----yarn.lock(215KB)

网友评论