node.js - How do i avoid variable from getting printed on nodejs service console? -
how avoid local variable getting printed on nodejs service console?
validation.js
function gethash(){ var hash = []; hash = //some logic create hash return hash; } var hashtable= gethash(); exports.validaterequest= function(request, path, httpmethod){ var status= validate(hashtable,request); //some logic validate request using hashtable return status; }
every time api call triggered, code invokes validaterequest
method hashtable
remains unchanged time. intend calculate hashtable once , re-use it. hence i'm using local variable gethash() called once during initialisation.
this works fine far implementation concerned. problem when start node.js service, hashtable printed on service console below. how can rid of this?
//code create hashtable function createhashtable() { var apis= require('../config/api.js'), apitable = []; (key in apis) { //some simple array split , value comparison operations apitable.push({ name: key, path: new regexp(apis[key].spec.path), method: apis[key].spec.method }) } return apitable; }
the issues createhashtable
function. had appended *
of paths in apis[key].spec.path
. being 'path' variable, *
make invalid path. hence error getting printed on console. after correcting code
var path=apis[key].spec.path + '/*'; apitable.push({ name: key, path: new regexp(path), method: apis[key].spec.method })
there no error in hash table generation. console looks clean.
Comments
Post a Comment