Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function GetService(serviceModel: ServiceModel): express.RequestHandler {
const handler = GetServiceHandler(serviceModel);
const azureUserAttributesMiddleware = AzureUserAttributesMiddleware(
serviceModel
);
const middlewaresWrap = withRequestMiddlewares(
AzureApiAuthMiddleware(new Set([UserGroup.ApiPublicServiceRead])),
ClientIpMiddleware,
azureUserAttributesMiddleware,
requiredServiceIdMiddleware
);
return wrapRequestHandler(
middlewaresWrap(
checkSourceIpForHandler(handler, (_, c, u, __) => ipTuple(c, u))
)
);
}
export function GetOpenapi(apiSpecs: object): express.RequestHandler {
return wrapRequestHandler(() =>
Promise.resolve(ResponseSuccessJson(apiSpecs))
);
}
export function GetServicesByRecipient(
serviceModel: ServiceModel,
senderServiceModel: SenderServiceModel
): express.RequestHandler {
const handler = GetServicesByRecipientHandler(senderServiceModel);
const azureUserAttributesMiddleware = AzureUserAttributesMiddleware(
serviceModel
);
const middlewaresWrap = withRequestMiddlewares(
AzureApiAuthMiddleware(new Set([UserGroup.ApiServiceByRecipientQuery])),
ClientIpMiddleware,
azureUserAttributesMiddleware,
RequiredParamMiddleware("fiscalcode", FiscalCode)
);
return wrapRequestHandler(
middlewaresWrap(
checkSourceIpForHandler(handler, (_, c, u, __) => ipTuple(c, u))
)
);
}
export function GetService(serviceModel: ServiceModel): express.RequestHandler {
const handler = GetServiceHandler(serviceModel);
const azureUserAttributesMiddleware = AzureUserAttributesMiddleware(
serviceModel
);
const middlewaresWrap = withRequestMiddlewares(
AzureApiAuthMiddleware(new Set([UserGroup.ApiServiceRead])),
ClientIpMiddleware,
azureUserAttributesMiddleware,
requiredServiceIdMiddleware
);
return wrapRequestHandler(
middlewaresWrap(
checkSourceIpForHandler(handler, (_, c, u, __) => ipTuple(c, u))
)
);
}
serviceModel: ServiceModel,
profileModel: ProfileModel
): express.RequestHandler {
const handler = GetProfileHandler(profileModel);
const azureUserAttributesMiddleware = AzureUserAttributesMiddleware(
serviceModel
);
const middlewaresWrap = withRequestMiddlewares(
AzureApiAuthMiddleware(
new Set([UserGroup.ApiLimitedProfileRead, UserGroup.ApiFullProfileRead])
),
ClientIpMiddleware,
azureUserAttributesMiddleware,
FiscalCodeMiddleware
);
return wrapRequestHandler(
middlewaresWrap(
checkSourceIpForHandler(handler, (_, c, u, __) => ipTuple(c, u))
)
);
}
export function GetMessages(
serviceModel: ServiceModel,
messageModel: MessageModel
): express.RequestHandler {
const handler = GetMessagesHandler(messageModel);
const middlewaresWrap = withRequestMiddlewares(
AzureApiAuthMiddleware(new Set([UserGroup.ApiMessageList])),
ClientIpMiddleware,
AzureUserAttributesMiddleware(serviceModel),
FiscalCodeMiddleware
);
return wrapRequestHandler(
middlewaresWrap(
checkSourceIpForHandler(handler, (_, c, u, __) => ipTuple(c, u))
)
);
}
export function GetInfo(serviceModel: ServiceModel): express.RequestHandler {
const azureUserAttributesMiddleware = AzureUserAttributesMiddleware(
serviceModel
);
const azureApiAuthMiddleware = AzureApiAuthMiddleware(
new Set([UserGroup.ApiInfoRead])
);
const middlewaresWrap = withRequestMiddlewares(
azureApiAuthMiddleware,
ClientIpMiddleware,
azureUserAttributesMiddleware
);
return wrapRequestHandler(
middlewaresWrap(
checkSourceIpForHandler(getInfoHandler, (_, c, u) => ipTuple(c, u))
)
);
}
serviceModel: ServiceModel,
profileModel: ProfileModel
): express.RequestHandler {
const handler = UpsertProfileHandler(profileModel);
const azureUserAttributesMiddleware = AzureUserAttributesMiddleware(
serviceModel
);
const middlewaresWrap = withRequestMiddlewares(
ContextMiddleware(),
AzureApiAuthMiddleware(new Set([UserGroup.ApiProfileWrite])),
ClientIpMiddleware,
azureUserAttributesMiddleware,
FiscalCodeMiddleware,
ProfilePayloadMiddleware
);
return wrapRequestHandler(
middlewaresWrap(
checkSourceIpForHandler(handler, (_, __, c, u, ___, ____) =>
ipTuple(c, u)
)
)
);
}
export function UpdateService(
serviceModel: ServiceModel
): express.RequestHandler {
const handler = UpdateServiceHandler(serviceModel);
const azureUserAttributesMiddleware = AzureUserAttributesMiddleware(
serviceModel
);
const middlewaresWrap = withRequestMiddlewares(
AzureApiAuthMiddleware(new Set([UserGroup.ApiServiceWrite])),
ClientIpMiddleware,
azureUserAttributesMiddleware,
requiredServiceIdMiddleware,
ServicePayloadMiddleware
);
return wrapRequestHandler(
middlewaresWrap(
checkSourceIpForHandler(handler, (_, c, u, __, ___) => ipTuple(c, u))
)
);
}
messageModel,
messageStatusModel,
notificationModel,
notificationStatusModel,
blobService
);
const middlewaresWrap = withRequestMiddlewares(
AzureApiAuthMiddleware(
new Set([UserGroup.ApiMessageRead, UserGroup.ApiMessageList])
),
ClientIpMiddleware,
AzureUserAttributesMiddleware(serviceModel),
FiscalCodeMiddleware,
RequiredParamMiddleware("id", NonEmptyString)
);
return wrapRequestHandler(
middlewaresWrap(
checkSourceIpForHandler(handler, (_, c, u, __, ___) => ipTuple(c, u))
)
);
}