Created
February 11, 2020 05:28
-
-
Save OrionStark/01c902bc1cb244de85f32109dc7c6b75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__getServiceInformation(request.app_id || '') | |
.then(service => { | |
let flag = false | |
const availableEndPoints = service.endpoints[request.method.toLowerCase()] || [] | |
const splittedRequestPath = request.path.replace(/^\/|\/$/g, '').split('/') | |
for ( let i = 0; i < availableEndPoints.length; i++ ) { | |
let splittedEndPointPath = availableEndPoints[i].replace(/^\/|\/$/g, '').split('/') | |
if ( splittedRequestPath.length === splittedEndPointPath.length ) { | |
let fractalCheckFlag = true | |
for ( let j = 0; j < splittedEndPointPath.length; j++ ) { | |
if ( splittedEndPointPath[j] !== splittedRequestPath[j] && splittedEndPointPath[j] !== '*' ) { | |
fractalCheckFlag = false | |
break | |
} | |
} | |
if ( fractalCheckFlag ) { | |
flag = true | |
break | |
} | |
} | |
} | |
if ( flag ) { // If method found | |
logModel.addLog(new logModel({ | |
path: request.path, | |
service: request.app_id, | |
ip_address: request.ip_address | |
})) | |
callback(request, service, null) | |
} else { | |
const err = { | |
type: 'NOT_FOUND', | |
module_source: 'request_resolver', | |
message: 'Request method is not found.' | |
} | |
callback(null, null, err) | |
} | |
}) | |
.catch(err => { | |
callback(null, null, err) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment