feat: add handler for troubleshooting

This commit is contained in:
Jacob Overgaard
2024-09-09 18:15:11 +02:00
parent 29293edb4e
commit a6236313c9
3 changed files with 34 additions and 15 deletions

View File

@@ -72,7 +72,7 @@ const handlers = [
...userGroupsHandlers,
...userHandlers,
...documentBlueprintHandlers,
serverHandlers.serverInformationHandler,
...serverHandlers.serverInformationHandlers,
];
switch (import.meta.env.VITE_UMBRACO_INSTALL_STATUS) {

View File

@@ -18,7 +18,7 @@ import { handlers as configHandlers } from './handlers/config.handlers.js';
export const handlers = [
serverHandlers.serverRunningHandler,
serverHandlers.serverInformationHandler,
...serverHandlers.serverInformationHandlers,
...manifestsHandlers.manifestEmptyHandlers,
...installHandlers,
...upgradeHandlers,

View File

@@ -3,7 +3,11 @@ import type {
ServerStatusResponseModel,
ServerInformationResponseModel,
} from '@umbraco-cms/backoffice/external/backend-api';
import { RuntimeLevelModel, RuntimeModeModel } from '@umbraco-cms/backoffice/external/backend-api';
import {
RuntimeLevelModel,
RuntimeModeModel,
ServerTroubleshootingResponseModel,
} from '@umbraco-cms/backoffice/external/backend-api';
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
export const serverRunningHandler = rest.get(umbracoPath('/server/status'), (_req, res, ctx) => {
@@ -36,15 +40,30 @@ export const serverMustUpgradeHandler = rest.get(umbracoPath('/server/status'),
);
});
export const serverInformationHandler = rest.get(umbracoPath('/server/information'), (_req, res, ctx) => {
return res(
// Respond with a 200 status code
ctx.status(200),
ctx.json<ServerInformationResponseModel>({
version: '14.0.0-preview004',
assemblyVersion: '14.0.0-preview004',
baseUtcOffset: '01:00:00',
runtimeMode: RuntimeModeModel.BACKOFFICE_DEVELOPMENT,
}),
);
});
export const serverInformationHandlers = [
rest.get(umbracoPath('/server/information'), (_req, res, ctx) => {
return res(
// Respond with a 200 status code
ctx.status(200),
ctx.json<ServerInformationResponseModel>({
version: '14.0.0-preview004',
assemblyVersion: '14.0.0-preview004',
baseUtcOffset: '01:00:00',
runtimeMode: RuntimeModeModel.BACKOFFICE_DEVELOPMENT,
}),
);
}),
rest.get(umbracoPath('/server/troubleshooting'), (_req, res, ctx) => {
return res(
// Respond with a 200 status code
ctx.status(200),
ctx.json<ServerTroubleshootingResponseModel>({
items: [
{ name: 'Umbraco base url', data: location.origin },
{ name: 'Mocked server', data: 'true' },
{ name: 'Umbraco version', data: '14.0.0-preview004' },
],
}),
);
}),
];