Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return async (_, __, ___, serviceModelPayload) => {
const errorOrService = servicePayloadToService(serviceModelPayload);
if (isLeft(errorOrService)) {
return ResponseErrorFromValidationErrors(Service)(errorOrService.value);
}
const service = errorOrService.value;
const errorOrCreatedService = await serviceModel.create(
service,
service.serviceId
);
return errorOrCreatedService.fold<
IResponseErrorQuery | IResponseSuccessJson
>(
error => ResponseErrorQuery("CreateServiceHandler error", error),
createdService =>
ResponseSuccessJson(retrievedServiceToPublic(createdService))
);
};
}
new Promise(resolve => {
const validation = type.decode(request.params[name]);
const result = validation.mapLeft(
ResponseErrorFromValidationErrors(type)
);
resolve(result);
});
}
new Promise(resolve => {
const validation = ApiService.decode(request.body);
const result = validation.mapLeft(
ResponseErrorFromValidationErrors(ApiService)
);
resolve(result);
});
new Promise(resolve => {
return resolve(
ApiNewMessageWithDefaults.decode(request.body).mapLeft(
ResponseErrorFromValidationErrors(ApiNewMessageWithDefaults)
)
);
});
new Promise(resolve => {
const validation = ExtendedProfile.decode(request.body);
const result = validation.mapLeft(
ResponseErrorFromValidationErrors(ExtendedProfile)
);
resolve(result);
});