core/routeHandler.js
/**
     * validateRequest - Request validator and renderer
     * @returns {undefined}
     */
Request validator and renderer
@returns {undefined}
Request validator and renderer @returns { undefined }
validateRequest() {
        var urlPath = this.urlObj.path; 
        if(urlPath.charAt(0)==='/'){
            urlPath = urlPath.substr(1); 
        }
        if (this.appRoutesKeys.includes(urlPath)) {
            var completeRoute = appRoutes[urlPath];
            if (typeof completeRoute !== 'undefined' && completeRoute !== null) {
                var controller = Object.keys(completeRoute)[0]; 
                var method = completeRoute[Object.keys(completeRoute)[0]]; 
                var scopeHanler = this;
                if (typeof method === 'undefined' || method === null) {
                    method = "index"; 
                }
                var requestData = {
                    type: this.request.method,
                    path: urlPath,
                    controller: controller,
                    method: method,
                    query: this.urlObj.query,
                    headers: this.request.headers,
                    body: this.request.body,
                    resp: this.response
                };
                fs.stat(appConstants.CONTROLLER_PATH + '/' + controller + 'Controller.js', function (err) {
                    if (!err) {
                        scopeHanler.loadController(controller, method, requestData);
                    } else if (err.code === 'ENOENT') {
                        scopeHanler.response.render('404', {error: err});
                        console.log(err);
                    }
                });
            } else {
                console.log(coreErrors.ROUTE_EMPTY + urlPath);
                this.response.render('404', {error: coreErrors.ROUTE_EMPTY +' : '+ urlPath});
            }
        } else {
            console.log(coreErrors.ROUTE_MISSING + urlPath);
            this.response.render('404', {error: coreErrors.ROUTE_MISSING +' : '+ urlPath});
        }
    }
validateRequest ( ) { var urlPath = this . urlObj . path ; if ( urlPath . charAt ( 0 ) === '/' ) { urlPath = urlPath . substr ( 1 ) ; } if ( this . appRoutesKeys . includes ( urlPath ) ) { var completeRoute = appRoutes [ urlPath ] ; if ( typeof completeRoute !== 'undefined' && completeRoute !== null ) { var controller = Object . keys ( completeRoute ) [ 0 ] ; var method = completeRoute [ Object . keys ( completeRoute ) [ 0 ] ] ; var scopeHanler = this ; if ( typeof method === 'undefined' || method === null ) { method = "index" ; } var requestData = { type : this . request . method , path : urlPath , controller : controller , method : method , query : this . urlObj . query , headers : this . request . headers , body : this . request . body , resp : this . response } ; fs . stat ( appConstants . CONTROLLER_PATH + '/' + controller + 'Controller.js' , function ( err ) { if ( ! err ) { scopeHanler . loadController ( controller , method , requestData ) ; } else if ( err . code === 'ENOENT' ) { scopeHanler . response . render ( '404' , { error : err } ) ; console . log ( err ) ; } } ) ; } else { console . log ( coreErrors . ROUTE_EMPTY + urlPath ) ; this . response . render ( '404' , { error : coreErrors . ROUTE_EMPTY + ' : ' + urlPath } ) ; } } else { console . log ( coreErrors . ROUTE_MISSING + urlPath ) ; this . response . render ( '404' , { error : coreErrors . ROUTE_MISSING + ' : ' + urlPath } ) ; } }
validateRequest - Request validator and renderer
 @returns {undefined}
validateRequest - Request validator and renderer @returns { undefined }
// controller //action // Default method // Check if controller File exists // Route defination missing error // Route Not found error