Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async processRequest(request: IReceiveRequest): Promise {
let response = new StreamingResponse();
if (!request) {
response.statusCode = StatusCodes.BAD_REQUEST;
response.setBody(`No request provided.`);
return response;
}
if (!request.verb || !request.path) {
response.statusCode = StatusCodes.BAD_REQUEST;
response.setBody(`Request missing verb and/or path. Verb: ${ request.verb }. Path: ${ request.path }`);
return response;
}
if (request.verb.toLocaleUpperCase() !== POST && request.verb.toLocaleUpperCase() !== GET) {
response.statusCode = StatusCodes.METHOD_NOT_ALLOWED;
response.setBody(`Invalid verb received. Only GET and POST are accepted. Verb: ${ request.verb }`);