Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pricesWithTax: {
histogram: {
field: groupByProduct ? 'priceWithTaxMin' : 'priceWithTax',
interval: searchConfig.priceRangeBucketInterval,
},
},
};
const { body }: { body: SearchResponseBody } = await this.client.search({
index: indexPrefix + (input.groupByProduct ? PRODUCT_INDEX_NAME : VARIANT_INDEX_NAME),
type: input.groupByProduct ? PRODUCT_INDEX_TYPE : VARIANT_INDEX_TYPE,
body: elasticSearchBody,
});
const { aggregations } = body;
if (!aggregations) {
throw new InternalServerError(
'An error occurred when querying Elasticsearch for priceRange aggregations',
);
}
const mapPriceBuckets = (b: { key: string; doc_count: number }) => ({
to: Number.parseInt(b.key, 10) + searchConfig.priceRangeBucketInterval,
count: b.doc_count,
});
return {
range: {
min: aggregations.minPrice.value || 0,
max: aggregations.maxPrice.value || 0,
},
rangeWithTax: {
min: aggregations.minPriceWithTax.value || 0,
max: aggregations.maxPriceWithTax.value || 0,
async onVendureBootstrap(): Promise {
const options = EmailPlugin.options;
if (isDevModeOptions(options)) {
this.transport = {
type: 'file',
raw: false,
outputPath: options.outputPath,
};
} else {
if (!options.transport) {
throw new InternalServerError(
`When devMode is not set to true, the 'transport' property must be set.`,
);
}
this.transport = options.transport;
}
this.templateLoader = new TemplateLoader(options.templatePath);
this.emailSender = new EmailSender();
this.generator = new HandlebarsMjmlGenerator();
if (isDevModeOptions(options) && options.mailboxPort !== undefined) {
this.devMailbox = new DevMailbox();
this.devMailbox.serve(options);
this.devMailbox.handleMockEvent((handler, event) => this.handleEvent(handler, event));
}