1.0.2 • Published 2 years ago
nuxt-elasticsearch v1.0.2
Nuxt Elasticsearch Module
Backend-only Elasticsearch Client for Nuxt server APIs
Author
Features
Quickly get a working Elasticsearch client into your Nuxt API endpoints. Full control over the client init options.
Quick Setup
- Add
nuxt-elasticsearch
dependency to your project
# Using pnpm
pnpm add -D nuxt-elasticsearch
# Using yarn
yarn add --dev nuxt-elasticsearch
# Using npm
npm install --save-dev nuxt-elasticsearch
- Add
nuxt-elasticsearch
to themodules
section ofnuxt.config.ts
, and pass in a config options block for your connection details
export default defineNuxtConfig({
modules: [
'nuxt-elasticsearch'
],
nuxtElasticsearch: {
clientOpts: {
node: 'https://localhost:9200',
auth: {
username: 'elastic',
password: 'elastic',
}
}
}
})
- Build an API endpoint and use the client:
export default defineEventHandler(async (event) => {
const { serverElasticsearchClient } = event.context
return await serverElasticsearchClient.ping()
})
Development
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release