This commit is contained in:
seb
2026-07-06 01:31:11 +02:00
commit 917930d0fa
34 changed files with 2912 additions and 0 deletions

33
src/endpoints/init.js Normal file
View 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(),
});
}