express-debug

express-debug is a development tool for express. expressdebug是一个用于express的开发工具。It's simple middleware that injects useful debugging output into your html, in a non-obstructive way.它是一个简单的中间件,以一种非阻塞的方式将有用的调试输出注入html。

It adds an 'EDT' tab to the right side of pages that, when clicked, displays info such as template variables (locals), current session, useful request data, and current template.它在页面右侧添加了一个“EDT”选项卡,单击该选项卡时,将显示模板变量(本地变量)、当前会话、有用的请求数据和当前模板等信息。

If your application doesn't serve HTML, no worries, a standalone express-debug panel is mounted at /express-debug. 如果您的应用程序不提供HTML,不用担心,一个独立的express debug面板将安装在/express-debugSee settings section for more information.有关详细信息,请参阅“设置”部分。

express-debug should NOT be used in production environments.不应在生产环境中使用express-debug。

Compatible with express 3 and 4, node 0.8+与express 3和4、Node 0.8兼容+

Screenshot of the tool in action正在运行的工具的屏幕截图

Usage

Install

npm install express-debug --save-dev

Use

var express = require('express');
var app = express();

require('express-debug')(app, {/* settings */});

/* ... application logic ... */

Settings设置

depth - How deep to recurse through printed objects. 在打印对象中递归的深度。 This is the default unless the print_obj function is passed an options object with a 'depth' property. (Default: 4)这是默认值,除非print_obj函数被传递给具有“depth”属性的options对象。(默认值:4

theme - Absolute path to a css file to include and override EDT's default css.css文件的绝对路径,以包括和覆盖EDT的默认css。

extra_panels - additional panels to show. 要显示的其他面板。See docs for custom panels有关自定义面板,请参阅文档 and included panels包括面板 for proper structure, each panel is an object (Default: [])以获得正确的结构,每个面板都是一个对象(默认值:[]

panels - allows changing the default panels (ex: remove a panel) (Default: ['locals', 'request', 'session', 'template', 'software_info', 'profile'])允许更改默认面板(例如:删除面板)(默认值:['locals', 'request', 'session', 'template', 'software_info', 'profile']

path - path to render standalone express-debug [set to null or false to disable] (Default: /express-debug)呈现独立快速调试的路径[设置为nullfalse以禁用](默认值:/express-debug

extra_attrs - If you need to add arbitrary attributes to the containing element of EDT, this allows you to. 如果需要将任意属性添加到EDT的包含元素中,这允许您。(For example, you may want to use "ng-non-bindable" if you're using angular) (Default: '')(例如,如果您使用的是angular,您可能希望使用“ng non bindable”(默认值:''

sort - Global option to determine sort order of printed object values. 用于确定打印对象值排序顺序的全局选项。false for default order, true for basic default sort, or a function to use for sort. See MDN Array sort (Default: false)

Panels

locals - app.locals, res.locals, and options passed to the template (merged into res.locals)

request - req info. ip, body, query, files, route info, cookies, headers

session - everything in req.session会话中的所有内容

template - view name, template file视图名称、模板文件

software_info - shows current versions of node and libraries installed locally (not globally installed packages!)显示本地安装的节点和库的当前版本(不是全局安装的软件包!)

profile - total req processing time. middleware, param, and route timings. 总请求处理时间。中间件、参数和路由计时。(not a default panel; does not work with express 4.x yet)(不是默认面板;不适用于express 4.x)

other_requests - shows details on non-page requests made to the server (not a default panel, use extra_panels setting to invoke. 显示向服务器发出的非页面请求的详细信息(不是默认面板,请使用extra_panels设置调用)。{extra_panels: ['other_requests']})

nav - links to every GET route in your app. 指向应用程序中每个GET路线的链接。(not a default panel)(不是默认面板)

Future

Changelog

License - MIT

Copyright (c) 2014 Tom Hunkapiller and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.