feat(medusa-plugin-algolia): Revamp Algolia search plugin (#3510)
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
export default async (container, options) => {
|
||||
try {
|
||||
const algoliaService = container.resolve("algoliaService")
|
||||
|
||||
await Promise.all(
|
||||
Object.entries(options.settings).map(([key, value]) =>
|
||||
algoliaService.updateSettings(key, value)
|
||||
)
|
||||
)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Logger, MedusaContainer } from "@medusajs/modules-sdk"
|
||||
import AlgoliaService from "../services/algolia"
|
||||
import { AlgoliaPluginOptions } from "../types"
|
||||
|
||||
export default async (
|
||||
container: MedusaContainer,
|
||||
options: AlgoliaPluginOptions
|
||||
) => {
|
||||
const logger: Logger = container.resolve("logger")
|
||||
try {
|
||||
const algoliaService: AlgoliaService = container.resolve("algoliaService")
|
||||
|
||||
const { settings } = options
|
||||
|
||||
await Promise.all(
|
||||
Object.entries(settings || {}).map(async ([indexName, value]) => {
|
||||
return await algoliaService.updateSettings(indexName, value)
|
||||
})
|
||||
)
|
||||
} catch (err) {
|
||||
// ignore
|
||||
logger.warn(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user