Update API response structure to include pagination metadata.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/c818a471-e356-4d5e-8f68-50e8c07bc1d5.jpg
This commit is contained in:
alphaeusmote
2025-04-09 14:44:02 +00:00
parent bbb0cbe1b0
commit 0a8c06c782
2 changed files with 39 additions and 6 deletions
+6 -6
View File
@@ -269,7 +269,7 @@ export function generatePaginationMetadata(
// If no pagination params were specified
if (limit === undefined) {
return {
pagination: {
metadata: {
totalRecords,
currentPage: 1,
totalPages: 1,
@@ -284,7 +284,7 @@ export function generatePaginationMetadata(
const totalPages = Math.ceil(totalRecords / limit);
// Prepare pagination metadata
const pagination = {
const metadata = {
totalRecords,
currentPage,
totalPages,
@@ -305,7 +305,7 @@ export function generatePaginationMetadata(
const nextUrl = new URL(url.pathname, url.origin);
nextUrl.search = params.toString();
pagination.nextPage = nextUrl.toString();
metadata.nextPage = nextUrl.toString();
}
// Previous page
@@ -316,11 +316,11 @@ export function generatePaginationMetadata(
const prevUrl = new URL(url.pathname, url.origin);
prevUrl.search = params.toString();
pagination.previousPage = prevUrl.toString();
metadata.previousPage = prevUrl.toString();
}
}
return { pagination };
return { metadata };
}
/**
@@ -419,7 +419,7 @@ The response will include pagination metadata with the following structure:
\`\`\`json
{
"data": [...], // The actual records
"pagination": {
"metadata": {
"totalRecords": 100, // Total number of records
"currentPage": 3, // Current page number (1-based)
"totalPages": 10, // Total number of pages
+33
View File
@@ -106,6 +106,7 @@ const swaggerOptions = {
lastLogon: { type: "string", format: "date-time" },
memberOf: { type: "array", items: { type: "string" } },
adProperties: { type: "object" },
objectType: { type: "string", enum: ["user"] },
},
},
AdGroup: {
@@ -122,6 +123,7 @@ const swaggerOptions = {
description: { type: "string" },
members: { type: "array", items: { type: "string" } },
adProperties: { type: "object" },
objectType: { type: "string", enum: ["group"] },
},
},
AdOrgUnit: {
@@ -136,6 +138,7 @@ const swaggerOptions = {
name: { type: "string" },
description: { type: "string" },
adProperties: { type: "object" },
objectType: { type: "string", enum: ["organizationalUnit"] },
},
},
AdComputer: {
@@ -154,6 +157,7 @@ const swaggerOptions = {
lastLogon: { type: "string", format: "date-time" },
enabled: { type: "boolean" },
adProperties: { type: "object" },
objectType: { type: "string", enum: ["computer"] },
},
},
AdDomain: {
@@ -170,6 +174,7 @@ const swaggerOptions = {
forestName: { type: "string" },
domainFunctionality: { type: "string" },
adProperties: { type: "object" },
objectType: { type: "string", enum: ["domain"] },
},
},
LdapAttribute: {
@@ -312,6 +317,34 @@ const swaggerOptions = {
},
},
},
PaginatedResponse: {
description: "Successful response with pagination metadata",
content: {
"application/json": {
schema: {
type: "object",
properties: {
data: {
type: "array",
items: {
type: "object"
}
},
metadata: {
type: "object",
properties: {
currentPage: { type: "integer" },
totalPages: { type: "integer" },
totalRecords: { type: "integer" },
nextPage: { type: "string", nullable: true },
previousPage: { type: "string", nullable: true }
}
}
}
}
}
}
}
},
},
security: [