Genesis
This commit is contained in:
33
src/endpoints/init.js
Normal file
33
src/endpoints/init.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { sendJson } from '../http.js';
|
||||
import { getMaxExternalId } from '../order-log.js';
|
||||
import { getCategoryCount } from '../queries/category-count.js';
|
||||
import { getCustomerGroupCount } from '../queries/customer-groups.js';
|
||||
import { getProductCount } from '../queries/product-count.js';
|
||||
|
||||
export const method = 'GET';
|
||||
export const path = '/v1/init';
|
||||
|
||||
export async function handle(_req, res, { url }) {
|
||||
const productCursor = Number(url.searchParams.get('lastChangedProduct')) || 0;
|
||||
const categoryCursor = Number(url.searchParams.get('lastChangedCategory')) || 0;
|
||||
const customerGroupCursor = Number(url.searchParams.get('lastChangedCustomerGroup')) || 0;
|
||||
|
||||
const [productCount, categoryCount, customerGroupCount] = await Promise.all([
|
||||
getProductCount({ cursor: productCursor }),
|
||||
getCategoryCount({ cursor: categoryCursor }),
|
||||
getCustomerGroupCount({ cursor: customerGroupCursor }),
|
||||
]);
|
||||
|
||||
return sendJson(res, 200, {
|
||||
version: '1.10.12.0',
|
||||
product_count: String(productCount),
|
||||
category_count: String(categoryCount),
|
||||
customer_count: '0',
|
||||
customerGroup_count: String(customerGroupCount),
|
||||
compositeProduct_count: '0',
|
||||
configurationGroup_count: '0',
|
||||
configurationItem_count: '0',
|
||||
deletedEntity_count: '0',
|
||||
max_orderId_count: getMaxExternalId(),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user