Ts.ED Plus Meilisearch
Support for Meilisearch in your Ts.ED application.
Contents
Prerequisite
If you have not already, familiarize yourself with the Ts.ED framework and Meilisearch.
Getting Started
Install Dependencies
# npm
npm install meilisearch
# yarn
yarn add meilisearch
Install Ts.ED Module
# npm
npm install @tsed-plus/meilisearch
# yarn
yarn add @tsed-plus/meilisearch
Configuration
Enable MeiliSearch through configuration and pass any additional option that the MeiliSearch constructor accepts
@Configuration({
// ...
meilisearch: {
enabled: true,
// plus any option that the MeiliSearch constructor accepts, e.g.
host: "127.0.0.1:7700",
},
})
export class Server {
Inject the Meilisearch Client
Inject the MeiliSearchService
in a service/controller of your choice.
import { Controller } from '@tsed/di';
import { Get } from '@tsed/schema';
import { MeiliSearchService } from '@tsed-plus/meilisearch';
@Controller('/')
export class HelloWorldController {
@Inject()
protected meilisearch: MeiliSearchService;
@Get('/')
async get() {
return this.meilisearch.getIndexes();
}
}