1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Make typing of routes support synchronous values

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-02-14 08:52:56 +02:00
parent 3f28a09fa1
commit 9117bc2760
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
3 changed files with 9 additions and 5 deletions

View File

@ -232,5 +232,11 @@ export interface LensApiResult<TResult> {
export interface Route<TResponse> {
path: string;
method: "get" | "post" | "put" | "patch" | "delete";
handler: (request: LensApiRequest) => LensApiResult<TResponse> | Promise<LensApiResult<TResponse>>;
handler: (
request: LensApiRequest
) =>
| Promise<LensApiResult<TResponse>>
| Promise<void>
| LensApiResult<TResponse>
| void;
}

View File

@ -17,7 +17,7 @@ const getMetricProvidersRouteInjectable = getInjectable({
method: "get",
path: `${apiPrefix}/metrics/providers`,
handler: async () => {
handler: () => {
const providers: MetricProviderInfo[] = [];
for (const { name, id, isConfigurable } of PrometheusProviderRegistry.getInstance().providers.values()) {

View File

@ -14,9 +14,7 @@ const getVersionRouteInjectable = getInjectable({
method: "get",
path: `/version`,
handler: async () => {
return { response: { version: getAppVersion() }};
},
handler: () => ({ response: { version: getAppVersion() }}),
}),
injectionToken: routeInjectionToken,