Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private buildCookieParserMiddleware() {
const args = [];
if (this.cookiesSecret) {
args.push(this.cookiesSecret);
}
if (this.cookiesDecoder) {
args.push({ decode: this.cookiesDecoder });
}
this.debugger.build('Creating cookie parser with options %j.', args);
const middleware = cookieParser.apply(this, args);
return middleware;
}
}
private buildServiceMiddleware(serviceMethod: ServiceMethod): Array {
let result: Array = new Array();
if (serviceMethod.mustParseCookies) {
let args = [];
if (InternalServer.cookiesSecret) {
args.push(InternalServer.cookiesSecret);
}
if (InternalServer.cookiesDecoder){
args.push({ decode: InternalServer.cookiesDecoder });
}
result.push(cookieParser.apply(this, args));
}
if (serviceMethod.mustParseBody) {
result.push(bodyParser.json());
//TODO adicionar parser de XML para o body
}
if (serviceMethod.mustParseForms) {
result.push(bodyParser.urlencoded({ extended: true }));
//TODO adicionar o multer para parsing arquivos
}
return result;
}
InternalServer.prototype.buildServiceMiddleware = function (serviceMethod) {
var result = new Array();
if (serviceMethod.mustParseCookies) {
var args = [];
if (InternalServer.cookiesSecret) {
args.push(InternalServer.cookiesSecret);
}
if (InternalServer.cookiesDecoder) {
args.push({ decode: InternalServer.cookiesDecoder });
}
result.push(cookieParser.apply(this, args));
}
if (serviceMethod.mustParseBody) {
result.push(bodyParser.json());
}
if (serviceMethod.mustParseForms || serviceMethod.acceptMultiTypedParam) {
result.push(bodyParser.urlencoded({ extended: true }));
}
if (serviceMethod.files.length > 0) {
var options_1 = new Array();
serviceMethod.files.forEach(function (fileData) {
if (fileData.singleFile) {
options_1.push({ "name": fileData.name, "maxCount": 1 });
}
else {
options_1.push({ "name": fileData.name });
}
value: function buildServiceMiddleware(serviceMethod) {
var result = new Array();
if (serviceMethod.mustParseCookies) {
var args = [];
if (InternalServer.cookiesSecret) {
args.push(InternalServer.cookiesSecret);
}
if (InternalServer.cookiesDecoder) {
args.push({ decode: InternalServer.cookiesDecoder });
}
result.push(cookieParser.apply(this, args));
}
if (serviceMethod.mustParseBody) {
result.push(bodyParser.json());
}
if (serviceMethod.mustParseForms) {
result.push(bodyParser.urlencoded({ extended: true }));
}
return result;
}
}, {