mirror of https://github.com/buster-so/buster.git
adding optional password on metric_file/[id]/data endpoint
This commit is contained in:
parent
152f95c768
commit
aed9732302
|
@ -12,10 +12,17 @@ const app = new Hono()
|
|||
zValidator('query', MetricDataQuerySchema),
|
||||
async (c) => {
|
||||
const { id } = c.req.valid('param');
|
||||
const { limit, version_number, report_file_id } = c.req.valid('query');
|
||||
const { limit, version_number, report_file_id, password } = c.req.valid('query');
|
||||
const user = c.get('busterUser');
|
||||
|
||||
const response = await getMetricDataHandler(id, user, limit, version_number, report_file_id);
|
||||
const response = await getMetricDataHandler(
|
||||
id,
|
||||
user,
|
||||
limit,
|
||||
version_number,
|
||||
report_file_id,
|
||||
password
|
||||
);
|
||||
|
||||
return c.json(response);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ export async function getMetricDataHandler(
|
|||
user: User,
|
||||
limit = 5000,
|
||||
versionNumber?: number,
|
||||
reportFileId?: string
|
||||
reportFileId?: string,
|
||||
password?: string
|
||||
): Promise<MetricDataResponse> {
|
||||
// Retrieve metric definition from database with data source info
|
||||
const metric = await getMetricWithDataSource({ metricId, versionNumber });
|
||||
|
@ -63,7 +64,7 @@ export async function getMetricDataHandler(
|
|||
publiclyAccessible: metric.publiclyAccessible,
|
||||
publicExpiryDate: metric.publicExpiryDate ?? undefined,
|
||||
publicPassword: metric.publicPassword ?? undefined,
|
||||
userSuppliedPassword: undefined,
|
||||
userSuppliedPassword: password,
|
||||
});
|
||||
|
||||
if (!hasAccess) {
|
||||
|
|
|
@ -54,8 +54,9 @@ export type MetricDataParams = z.infer<typeof MetricDataParamsSchema>;
|
|||
*/
|
||||
export const MetricDataQuerySchema = z.object({
|
||||
limit: z.coerce.number().min(1).max(5000).default(5000).optional(),
|
||||
version_number: z.coerce.number().optional(),
|
||||
version_number: z.coerce.number().int().min(1).optional(),
|
||||
report_file_id: z.string().uuid().optional(),
|
||||
password: z.string().min(1).optional(),
|
||||
});
|
||||
|
||||
export type MetricDataQuery = z.infer<typeof MetricDataQuerySchema>;
|
||||
|
|
Loading…
Reference in New Issue