feat: Introduce renderer helper

This commit is contained in:
Faruk AYDIN
2024-02-12 23:25:09 +01:00
parent c81531cb7a
commit 4f03f2ab51
3 changed files with 35 additions and 4 deletions

View File

@@ -0,0 +1,18 @@
const renderObject = (response, object) => {
const isArray = Array.isArray(object);
const computedPayload = {
data: object,
meta: {
type: object.constructor.name,
count: isArray ? object.length : 1,
isArray,
currentPage: null,
totalPages: null,
},
};
return response.json(computedPayload);
};
export { renderObject };