@@ -19,7 +19,7 @@ const _ = require("lodash");
1919const bodyParser = require ( "body-parser" ) ;
2020const serveStatic = require ( "serve-static" ) ;
2121const isReadableStream = require ( "isstream" ) . isReadable ;
22- const { pipeline } = require ( ' stream' ) ;
22+ const { pipeline } = require ( " stream" ) ;
2323
2424const { MoleculerError, MoleculerServerError, ServiceNotFoundError } = require ( "moleculer" ) . Errors ;
2525const { ServiceUnavailableError, NotFoundError, ForbiddenError, RateLimitExceeded, ERR_ORIGIN_NOT_ALLOWED } = require ( "./errors" ) ;
@@ -521,6 +521,14 @@ module.exports = {
521521 }
522522 }
523523
524+ // Blacklist check
525+ if ( alias . action && route . hasBlacklist ) {
526+ if ( this . checkBlacklist ( route , alias . action ) ) {
527+ this . logger . debug ( ` The '${ alias . action } ' action is in the blacklist!` ) ;
528+ throw new ServiceNotFoundError ( { action : alias . action } ) ;
529+ }
530+ }
531+
524532 // Rate limiter
525533 if ( route . rateLimit ) {
526534 const opts = route . rateLimit ;
@@ -822,9 +830,9 @@ module.exports = {
822830 if ( isReadableStream ( data ) ) { //Stream response
823831 pipeline ( data , res , err => {
824832 if ( err ) {
825- this . logger . warn ( "Stream got an error." , { err, url : req . url , actionName : action . name } )
833+ this . logger . warn ( "Stream got an error." , { err, url : req . url , actionName : action . name } ) ;
826834 }
827- } )
835+ } ) ;
828836 } else {
829837 res . end ( chunk ) ;
830838 }
@@ -1546,12 +1554,12 @@ module.exports = {
15461554
15471555 // Blacklist check
15481556 if ( route . hasBlacklist ) {
1549- if ( this . checkBlacklist ( route , alias . action ) ) {
1557+ if ( this . checkBlacklist ( route , action . name ) ) {
15501558 this . logger . debug (
1551- ` The '${ alias . action } ' action is in the blacklist!`
1559+ ` The '${ action . name } ' action is in the blacklist!`
15521560 ) ;
15531561 throw new ServiceNotFoundError ( {
1554- action : alias . action ,
1562+ action : action . name ,
15551563 } ) ;
15561564 }
15571565 }
0 commit comments