-
-
Notifications
You must be signed in to change notification settings - Fork 22.7k
feat: add diagnostics_channel support for app initialization #7041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| 'use strict'; | ||
|
|
||
| const dc = require('node:diagnostics_channel'); | ||
|
|
||
| const initialization = dc.channel('express.initialization'); | ||
|
|
||
| module.exports = { initialization }; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ var proto = require('./application'); | |||||
| var Router = require('router'); | ||||||
| var req = require('./request'); | ||||||
| var res = require('./response'); | ||||||
| const channels = require('./diagnostics'); | ||||||
|
||||||
| const channels = require('./diagnostics'); | |
| var channels = require('./diagnostics'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| 'use strict' | ||
|
|
||
| const dc = require('node:diagnostics_channel') | ||
| const express = require('../') | ||
| const assert = require('node:assert') | ||
|
|
||
| describe('diagnostics channels', function () { | ||
| describe('express.initialization', function () { | ||
| it('should publish when app is created', function () { | ||
| let msg | ||
|
|
||
| dc.subscribe('express.initialization', function handler (data) { | ||
| msg = data | ||
| dc.unsubscribe('express.initialization', handler) | ||
| }) | ||
|
|
||
| const app = express() | ||
| assert.ok(msg, 'express.initialization was not published') | ||
| assert.strictEqual(msg.app, app) | ||
| }) | ||
|
|
||
| it('should not throw when there are no subscribers', function () { | ||
| assert.ok(express()) | ||
| }) | ||
| }) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The codebase convention for top-level requires in lib/ files is to use
varrather thanconst. This pattern is consistently followed across all other lib/ files (application.js, request.js, response.js, utils.js, view.js, express.js). Whileconstis used in the codebase for destructuring and local variables inside functions, top-level requires should usevarfor consistency with the rest of the codebase.