1.0.2 • Published 10 months ago

nuxt-elasticsearch v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Nuxt Elasticsearch Module

npm version npm downloads License Nuxt

Backend-only Elasticsearch Client for Nuxt server APIs

Author

Chris Pappas

Features

Quickly get a working Elasticsearch client into your Nuxt API endpoints. Full control over the client init options.

Quick Setup

  1. 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
  1. Add nuxt-elasticsearch to the modules section of nuxt.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',
      }
    }
  }
})
  1. 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

License

MIT License

1.0.2

10 months ago

1.0.1

10 months ago