lib/swsInterface.js
function (options) {

        processOptions(options);

        processor = new swsProcessor();
        processor.init(swsOptions);

        return function trackingMiddleware(req, res, next) {

            // Respond to requests handled by swagger-stats
            // swagger-stats requests will not be counted in statistics
            if(req.url.startsWith(pathStats)) {
                return processGetStats(req, res);
            }else if(req.url.startsWith(pathMetrics)){
                return processGetMetrics(req,res);
            }else if(req.url.startsWith(pathLogout)){
                processLogout(req,res);
                return;
            }else if(req.url.startsWith(pathUI) ){
                res.status(200).send(uiMarkup);
                return;
            }else if(req.url.startsWith(pathDist)) {
                var fileName = req.url.replace(pathDist+'/','');
                var qidx = fileName.indexOf('?');
                if(qidx!=-1) fileName = fileName.substring(0,qidx);

                var options = {
                    root: path.join(__dirname,'..','dist'),
                    dotfiles: 'deny'
                    // TODO Caching
                };
                res.sendFile(fileName, options, function (err) {
                    if (err) {
                        debug('unable to send file: %s',fileName);
                    }
                });
                return;
            }

            handleRequest(req, res);

            return next();
        };
    }
function (options) {

        processOptions(options);

        processor = new swsProcessor();
        processor.init(swsOptions);

        return function trackingMiddleware(req, res, next) {

            // Respond to requests handled by swagger-stats
            // swagger-stats requests will not be counted in statistics
            if(req.url.startsWith(pathStats)) {
                return processGetStats(req, res);
            }else if(req.url.startsWith(pathMetrics)){
                return processGetMetrics(req,res);
            }else if(req.url.startsWith(pathLogout)){
                processLogout(req,res);
                return;
            }else if(req.url.startsWith(pathUI) ){
                res.status(200).send(uiMarkup);
                return;
            }else if(req.url.startsWith(pathDist)) {
                var fileName = req.url.replace(pathDist+'/','');
                var qidx = fileName.indexOf('?');
                if(qidx!=-1) fileName = fileName.substring(0,qidx);

                var options = {
                    root: path.join(__dirname,'..','dist'),
                    dotfiles: 'deny'
                    // TODO Caching
                };
                res.sendFile(fileName, options, function (err) {
                    if (err) {
                        debug('unable to send file: %s',fileName);
                    }
                });
                return;
            }

            handleRequest(req, res);

            return next();
        };
    }
function ( options ) { processOptions ( options ) ; processor = new swsProcessor ( ) ; processor . init ( swsOptions ) ; return function trackingMiddleware ( req , res , next ) { // Respond to requests handled by swagger-stats // swagger-stats requests will not be counted in statistics if ( req . url . startsWith ( pathStats ) ) { return processGetStats ( req , res ) ; } else if ( req . url . startsWith ( pathMetrics ) ) { return processGetMetrics ( req , res ) ; } else if ( req . url . startsWith ( pathLogout ) ) { processLogout ( req , res ) ; return ; } else if ( req . url . startsWith ( pathUI ) ) { res . status ( 200 ) . send ( uiMarkup ) ; return ; } else if ( req . url . startsWith ( pathDist ) ) { var fileName = req . url . replace ( pathDist + '/' , '' ) ; var qidx = fileName . indexOf ( '?' ) ; if ( qidx != - 1 ) fileName = fileName . substring ( 0 , qidx ) ; var options = { root : path . join ( __dirname , '..' , 'dist' ) , dotfiles : 'deny' // TODO Caching } ; res . sendFile ( fileName , options , function ( err ) { if ( err ) { debug ( 'unable to send file: %s' , fileName ) ; } } ) ; return ; } handleRequest ( req , res ) ; return next ( ) ; } ; }
Initialize swagger-stats and return middleware to perform API Data collection
Initialize swagger - stats and return middleware to perform API Data collection