npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

strapi-plugin-meilisearch-client

v1.1.2

Published

Register a Meilisearch endpoint for Strapi Headless CMS.

Downloads

2

Readme

Strapi-plugin-meilisearch-client

This plugin adds a search endpoint to Meilisearch Strapi Plugin.

Requirements

Strapi Version v4.x.x Meilisearch Strapi Plugin v4.x.x

Installation

Enable the meilisearch-client plugin in the ./config/plugins.js of your Strapi project.

Make sure to set the appropriate permissions for the search route in the Permissions tab of the Users & Permission Plugin for the role to be able to access the search route.

Options/Config

Mandatory settings are marked with *.

General Options

In order to register serchable content types when Strapi starts, this plugin requires the following configurations to be set in the .config/plugins.js file of your Strapi project to work.

| Key | Type | Notes                                               | | -------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | contentTypes* | Array of Objects | List the content types you want to register. Each object requires the uid: string and modelName: string to be set for a content type | | minQueryLength | int (positive) | Requires query to have at least that many characters, otherwise returns no result |

Full Example config

module.exports = ({ env }) => ({
  // ...

  "meilisearch-client": {
    enabled: true,
    config: {
      contentTypes: [
        {
          uid: "api::author.author",
          modelName: "author",
          limit: 10,
        },
        {
          uid: "api::book.book",
          modelName: "book",
        },
      ],
      minQueryLength: 3,
    },
  },

  // ...
});

Usage

Search

Hitting the /api/meilisearch-client/search?query=<your-query-string> will return an array of matched entries for each content type registered in the config. If no match could be found an empty array will be returned. The endpoint accepts an optional locale=<your-locale> query as well.

Alternatively (and if the graphql plugin is installed), a search query is registered that accepts query: String! and locale: I18NLocaleCode (optional) as arguments.

IMPORTANT: Please not that in order to query for the locale of a content type, localization must be enabled for the content type.

Examples

Example Requests

REST

await fetch(`${API_URL}/api/meilisearch-client/search?query=john&locale=en`);
// GET /api/meilisearch-client/search?query=john&locale=en

GraphQl

query {
  search(query: "john", locale: "en") {
    authors {
      data {
        attributes {
          name
        }
      }
    }
    books {
      data {
        attributes {
          title
          description
        }
      }
    }
  }
}

Example Responses

REST

{
  "authors": [
    {
      "id": 1,
      "name": "John Doe",
      "description": "John Doe ist an amazing author that is famous for his book \"The Rising Star\". In his works he likes to describe feelings of happiness and contempt using colorful metaphors.",
      "createdAt": "2022-05-05T13:08:19.312Z",
      "updatedAt": "2022-05-05T13:34:46.488Z",
      "publishedAt": "2022-05-05T13:22:17.310Z"
    }
  ],
  "books": [
    {
      "id": 1,
      "title": "The Rising Star",
      "description": "The Rising Star is a beautiful book written by John Doe.",
      "createdAt": "2022-05-05T13:08:43.816Z",
      "updatedAt": "2022-05-05T13:24:07.107Z",
      "publishedAt": "2022-05-05T13:22:23.764Z"
    }
  ]
}

GraphQl

{
  "data": {
    "search": {
      "authors": {
        "data": [
          {
            "attributes": {
              "name": "John Doe"
            }
          }
        ]
      },
      "books": {
        "data": [
          {
            "attributes": {
              "title": "The Rising Star",
              "description": "The Rising Star is a beautiful book written by John Doe."
            }
          }
        ]
      }
    }
  }
}

Found a bug?

If you found a bug or have any questions please submit an issue. If you think you found a way how to fix it, please feel free to create a pull request!