nuxt-elasticsearch
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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

/nuxt-elasticsearch/

    Package Sidebar

    Install

    npm i nuxt-elasticsearch

    Weekly Downloads

    0

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    7.4 kB

    Total Files

    12

    Last publish

    Collaborators

    • chrispappas