This commit is contained in:
seb
2026-08-01 02:15:21 +02:00
parent 59c874144b
commit 69a24192d3
8 changed files with 206 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import { GET_CATEGORY_ID_BY_SKU } from '../../sql/article.js';
import resolveCategoryAccess from '../category/resolveCategoryAccess.js';
export default function resolveArticleBySku(pool) {
const access = resolveCategoryAccess(pool);
return async (googleAuthId, sku) => {
const lookup = await pool
.request()
.input('sku', sku)
.query(GET_CATEGORY_ID_BY_SKU);
const row = lookup.recordset[0];
if (!row?.categoryId || !row?.articleId) {
throw new Error('Article not found');
}
await access(googleAuthId, row.categoryId);
return {
articleId: row.articleId,
categoryId: row.categoryId,
};
};
}