Connect local write permissions to backend
This commit is contained in:
@@ -230,6 +230,9 @@ function getRequestConfig(request) {
|
||||
database: {
|
||||
...config.database,
|
||||
mode: selectedMode,
|
||||
allowWrites: selectedMode === "local"
|
||||
&& config.database.allowWrites
|
||||
&& request.headers["x-local-write-access"] === "1",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,12 +13,14 @@ import {
|
||||
|
||||
export async function loadManufacturerCatalogState(config, { manufacturerId, position = 1 }) {
|
||||
const refreshResults = [];
|
||||
for (const sql of prepareManufacturerCatalogSqls({ manufacturerId })) {
|
||||
refreshResults.push(
|
||||
await executeEndpointWrite(config, sql, {
|
||||
operation: "catalog-maker-refresh-manufacturer",
|
||||
}),
|
||||
);
|
||||
if (config.database?.mode === "local" && config.database.allowWrites) {
|
||||
for (const sql of prepareManufacturerCatalogSqls({ manufacturerId })) {
|
||||
refreshResults.push(
|
||||
await executeEndpointWrite(config, sql, {
|
||||
operation: "catalog-maker-refresh-manufacturer",
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const productResult = await queryEndpoint(
|
||||
@@ -49,6 +51,7 @@ export async function loadManufacturerCatalogState(config, { manufacturerId, pos
|
||||
refresh: {
|
||||
operation: "catalog-maker-refresh-manufacturer",
|
||||
statements: refreshResults.length,
|
||||
skipped: refreshResults.length === 0,
|
||||
},
|
||||
product: normalizeProduct(product),
|
||||
combinations: combinationsResult.items.map(normalizeCombination),
|
||||
|
||||
Reference in New Issue
Block a user