Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix typecheck

Carl-Gerhard Lindesvärd04375807d015
diff --git a/apps/api/src/controllers/export.controller.ts b/apps/api/src/controllers/export.controller.ts
index d5b4ffc04..0e442b890 100644
--- a/apps/api/src/controllers/export.controller.ts
+++ b/apps/api/src/controllers/export.controller.ts
@@ -9,6 +9,7 @@ type EventsQuery = {
start?: string;
end?: string;
page?: string;
+ limit?: string;
};
export async function events(
request: FastifyRequest<{
@@ -17,6 +18,8 @@ export async function events(
reply: FastifyReply
) {
const query = request.query;
+ const limit = parseInt(query.limit || '50', 10);
+ const page = parseInt(query.page || '1', 10);
if (query.project_id) {
if (
@@ -56,8 +59,8 @@ export async function events(
return;
}
- const take = Math.max(Math.min(query.limit, 50), 1);
- const cursor = (parseInt(query.page || '1', 10) || 1) - 1;
+ const take = Math.max(Math.min(limit, 50), 1);
+ const cursor = page - 1;
const options: GetEventListOptions = {
projectId,
events: (Array.isArray(query.event) ? query.event : [query.event]).filter(
@@ -78,7 +81,6 @@ export async function events(
reply.send({
meta: {
- // options,
count: data.length,
totalCount: totalCount,
pages: Math.ceil(totalCount / options.take),