Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[reporting] Pass along generic parameters in high-order route handler" #74891

Merged
merged 1 commit into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions x-pack/plugins/reporting/server/routes/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export function registerJobInfoRoutes(reporting: ReportingCore) {
const {
management: { jobTypes = [] },
} = await reporting.getLicenseInfo();
const { page: queryPage = '0', size: querySize = '10', ids: queryIds = null } = req.query;
const {
page: queryPage = '0',
size: querySize = '10',
ids: queryIds = null,
} = req.query as ListQuery; // NOTE: type inference is not working here. userHandler breaks it?
const page = parseInt(queryPage, 10) || 0;
const size = Math.min(100, parseInt(querySize, 10) || 10);
const jobIds = queryIds ? queryIds.split(',') : null;
Expand Down Expand Up @@ -112,7 +116,7 @@ export function registerJobInfoRoutes(reporting: ReportingCore) {
return handleUnavailable(res);
}

const { docId } = req.params;
const { docId } = req.params as { docId: string };
const {
management: { jobTypes = [] },
} = await reporting.getLicenseInfo();
Expand Down Expand Up @@ -157,7 +161,7 @@ export function registerJobInfoRoutes(reporting: ReportingCore) {
return res.custom({ statusCode: 503 });
}

const { docId } = req.params;
const { docId } = req.params as { docId: string };
const {
management: { jobTypes = [] },
} = await reporting.getLicenseInfo();
Expand Down Expand Up @@ -209,7 +213,7 @@ export function registerJobInfoRoutes(reporting: ReportingCore) {
return handleUnavailable(res);
}

const { docId } = req.params;
const { docId } = req.params as { docId: string };
const {
management: { jobTypes = [] },
} = await reporting.getLicenseInfo();
Expand All @@ -235,7 +239,7 @@ export function registerJobInfoRoutes(reporting: ReportingCore) {
return handleUnavailable(res);
}

const { docId } = req.params;
const { docId } = req.params as { docId: string };
const {
management: { jobTypes = [] },
} = await reporting.getLicenseInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getUserFactory } from './get_user';
type ReportingUser = AuthenticatedUser | null;
const superuserRole = 'superuser';

export type RequestHandlerUser<P, Q, B> = RequestHandler<P, Q, B> extends (...a: infer U) => infer R
export type RequestHandlerUser = RequestHandler extends (...a: infer U) => infer R
? (user: ReportingUser, ...a: U) => R
: never;

Expand All @@ -21,7 +21,7 @@ export const authorizedUserPreRoutingFactory = function authorizedUserPreRouting
) {
const setupDeps = reporting.getPluginSetupDeps();
const getUser = getUserFactory(setupDeps.security);
return <P, Q, B>(handler: RequestHandlerUser<P, Q, B>): RequestHandler<P, Q, B, RouteMethod> => {
return <P, Q, B>(handler: RequestHandlerUser): RequestHandler<P, Q, B, RouteMethod> => {
return (context, req, res) => {
let user: ReportingUser = null;
if (setupDeps.security && setupDeps.security.license.isEnabled()) {
Expand Down