Add debug logs for CMS
This commit is contained in:
parent
ba7c3de471
commit
7c9a9a2890
3 changed files with 20 additions and 28 deletions
5
.changeset/little-bats-wonder.md
Normal file
5
.changeset/little-bats-wonder.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"saleor-app-cms": minor
|
||||
---
|
||||
|
||||
Added additional debug logs for "ping" endpoint. In case of failed connection, logs can be checked for details. Endpoint also will return error to the frontend
|
|
@ -14,6 +14,7 @@ export interface ProviderInstancePingApiPayload {
|
|||
|
||||
export interface ProviderInstancePingApiResponse {
|
||||
success: boolean;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
const handler: NextProtectedApiHandler = async (
|
||||
|
@ -51,22 +52,30 @@ const handler: NextProtectedApiHandler = async (
|
|||
const providerInstanceSettings = providerInstancesSettingsParsed[providerInstanceId];
|
||||
|
||||
if (!providerInstanceSettings) {
|
||||
logger.debug("Settings not found, returning 400");
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const pingResult = await pingProviderInstance(providerInstanceSettings);
|
||||
|
||||
if (!pingResult.ok) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
});
|
||||
}
|
||||
|
||||
if (pingResult.ok) {
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
});
|
||||
} else {
|
||||
throw pingResult;
|
||||
}
|
||||
} catch (e) {
|
||||
logger.debug(e, "Failed connecting to the CMS");
|
||||
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: JSON.stringify(e),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default createProtectedHandler(handler, saleorApp.apl, ["MANAGE_APPS"]);
|
||||
|
|
|
@ -5559,28 +5559,6 @@ packages:
|
|||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
/@saleor/app-sdk@0.38.0(next@13.3.0)(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-JS/E3YODFHc+1DI+PczbV8jB09nLwzdQcwNs681RlwvR3JUC892hdBYYRdBKG5lauAcr4IxKw1IbrsxJKngtWA==}
|
||||
peerDependencies:
|
||||
next: '>=12'
|
||||
react: '>=17'
|
||||
react-dom: '>=17'
|
||||
dependencies:
|
||||
'@changesets/cli': 2.26.0
|
||||
debug: 4.3.4
|
||||
fast-glob: 3.2.12
|
||||
graphql: 16.6.0
|
||||
jose: 4.11.4
|
||||
next: 13.3.0(@babel/core@7.21.4)(react-dom@18.2.0)(react@18.2.0)
|
||||
raw-body: 2.5.1
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
retes: 0.33.0
|
||||
uuid: 8.3.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@saleor/macaw-ui@0.7.2(@material-ui/core@4.12.4)(@material-ui/icons@4.11.3)(@material-ui/lab@4.0.0-alpha.61)(@types/react@18.0.14)(react-dom@18.2.0)(react-helmet@6.1.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-Fli7fhTWuHu7q2CzxwTUpB4x9HYaxHSAzCLZLA23VY1ieIWbCxbsXadMiMGWp/nuYitswMr6JXMm+1SDe9K8LQ==}
|
||||
engines: {node: '>=16 <19'}
|
||||
|
|
Loading…
Reference in a new issue