File tree Expand file tree Collapse file tree 6 files changed +878
-78
lines changed
Expand file tree Collapse file tree 6 files changed +878
-78
lines changed Original file line number Diff line number Diff line change 1- node_modules
1+ node_modules
2+ yarn-error.log
Original file line number Diff line number Diff line change @@ -64,7 +64,9 @@ Service configuration options
6464``` js
6565app .configure (debuggerService ({
6666 expireAfterSeconds: 900 , // Expire item in storage after x seconds, default is 900 (optional)
67- filename: ' nedb.db' // set filename if you want to persist data (optional)
67+ filename: ' nedb.db' , // set filename if you want to persist data (optional)
68+ ui: true // if you want to expose UI on publicUrl (default is false) and debug without chrome extension
69+ publicUrl: ' /debugger' // set custom url for debugger (default is /debugger), used only if ui: true
6870}))
6971```
7072
Original file line number Diff line number Diff line change 26262727 },
2828 "devDependencies" : {
29+ "@feathersjs/express" : " ^4.x.x" ,
2930 "eslint" : " ^7.7.0" ,
3031 "eslint-config-prettier" : " ^6.11.0" ,
3132 "eslint-import-resolver-node" : " ^0.3.4" ,
3536 "prettier" : " ^2.0.5"
3637 },
3738 "dependencies" : {
39+ "feathers-debugger" : " ^1.x.x" ,
3840 "feathers-nedb" : " ^5.1.0" ,
3941 "nedb" : " ^1.8.0"
42+ },
43+ "peerDependencies" : {
44+ "@feathersjs/express" : " ^4.x.x"
4045 }
4146}
Original file line number Diff line number Diff line change @@ -2,8 +2,12 @@ const NeDB = require('nedb');
22const service = require ( 'feathers-nedb' ) ;
33const traceHook = require ( './trace' ) ;
44const hooks = require ( './hooks' ) ;
5+ const path = require ( 'path' ) ;
6+ const express = require ( '@feathersjs/express' ) ; // eslint-disable-line
57
6- const configureService = ( options = { } ) => ( app ) => {
8+ const configureService = ( options = { ui : false , publicUrl : '/debugger' } ) => (
9+ app
10+ ) => {
711 // Create a NeDB instance
812 const Model = new NeDB ( {
913 filename : options . filename ,
@@ -20,6 +24,16 @@ const configureService = (options = {}) => (app) => {
2024
2125 app . use ( '/feathers-debugger' , service ( { Model } ) ) ;
2226 app . service ( 'feathers-debugger' ) . hooks ( hooks ( { Model } ) ) ;
27+ // Expose UI on endpoint if ui: true
28+ if ( options . ui ) {
29+ const publicUrl = options . publicUrl || '/debugger' ;
30+ const target = path . join (
31+ __dirname ,
32+ '../node_modules/feathers-debugger/dist'
33+ ) ;
34+ console . log ( '✨ Feathers Debugger exposed on:' , publicUrl ) ;
35+ app . use ( publicUrl , express . static ( target ) ) ;
36+ }
2337} ;
2438
2539module . exports = configureService ;
Original file line number Diff line number Diff line change @@ -3,16 +3,18 @@ module.exports = (
33) => async ( ctx ) => {
44 const service = ctx . app . service ( 'feathers-debugger' ) ;
55
6- // Error Message if service is not registered
6+ // Skip the hook if service is not registered
77 if ( ! service ) {
8- return console . warn (
9- 'WARN: Service feathers-debuger is not registered, feathers debugger tracing is disabled. Please check Feathers Debugger documentation on how to setup: https://github.com/radenkovic/feathers-debugger.'
10- ) ;
8+ return ;
119 }
1210 if ( ctx . path === 'feathers-debugger' ) return ;
1311
1412 if ( ! ctx . _req_ts ) {
1513 ctx . _req_ts = Date . now ( ) ;
14+ if ( ! ctx . params . provider ) {
15+ // Add artificial 1ms
16+ ctx . _req_ts += 1 ;
17+ }
1618 } else {
1719 ctx . _req_duration = Date . now ( ) - ctx . _req_ts ;
1820 }
@@ -25,7 +27,7 @@ module.exports = (
2527 provider : ctx . params ? ctx . params . provider : undefined ,
2628 ts : ctx . _req_ts ,
2729 duration : ctx . _req_duration ,
28- data : ctx . data ,
30+ data : JSON . stringify ( ctx . data ) ,
2931 error : ctx . error ? ctx . error . message : undefined ,
3032 end : Date . now ( ) ,
3133 } ;
You can’t perform that action at this time.
0 commit comments