@fastify/elasticsearch 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,8 @@ on:
17
17
 
18
18
  jobs:
19
19
  test:
20
- uses: fastify/workflows/.github/workflows/plugins-ci-elasticsearch.yml@v4.2.0
20
+ uses: fastify/workflows/.github/workflows/plugins-ci-elasticsearch.yml@v5
21
21
  with:
22
22
  lint: true
23
23
  license-check: true
24
+ elasticsearch-version: 8.15.2
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @fastify/elasticsearch
2
2
 
3
- ![CI](https://github.com/fastify/fastify-elasticsearch/workflows/CI/badge.svg)
3
+ [![CI](https://github.com/fastify/fastify-elasticsearch/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-elasticsearch/actions/workflows/ci.yml)
4
4
  [![NPM version](https://img.shields.io/npm/v/@fastify/elasticsearch.svg?style=flat)](https://www.npmjs.com/package/@fastify/elasticsearch)
5
- [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
5
+ [![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)
6
6
 
7
- Fastify plugin for [Elasticsearch](https://www.elastic.co/elasticsearch/) for sharing the same ES client in every part of your server.
7
+ Fastify plugin for [Elasticsearch](https://www.elastic.co/elasticsearch/) for sharing the same ES client in every part of your server.
8
8
  Under the hood, the official [elasticsearch](https://www.npmjs.com/package/@elastic/elasticsearch) module is used.
9
9
 
10
10
 
@@ -14,8 +14,22 @@ Under the hood, the official [elasticsearch](https://www.npmjs.com/package/@elas
14
14
  npm i @fastify/elasticsearch
15
15
  ```
16
16
 
17
+ ### Compatibility
18
+ | Plugin version | Fastify version |
19
+ | ---------------|-----------------|
20
+ | `^4.x` | `^5.x` |
21
+ | `^3.x` | `^4.x` |
22
+ | `^2.x` | `^3.x` |
23
+ | `^1.x` | `^2.x` |
24
+ | `^1.x` | `^1.x` |
25
+
26
+
27
+ Please note that if a Fastify version is out of support, then so are the corresponding versions of this plugin
28
+ in the table above.
29
+ See [Fastify's LTS policy](https://github.com/fastify/fastify/blob/main/docs/Reference/LTS.md) for more details.
30
+
17
31
  ## Usage
18
- Add it to your project with `register` and you are done!
32
+ Add it to your project with `register` and you are done!
19
33
  The plugin accepts the [same options](https://github.com/elastic/elasticsearch-js#client-options) as the client.
20
34
 
21
35
  ```js
@@ -78,7 +92,7 @@ fastify.listen({ port: 3000 }, err => {
78
92
  ```
79
93
 
80
94
  ## Versioning
81
- By default the latest and greatest version of the Elasticsearch client is used, see the [compatibility](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/introduction.html#_compatibility) table to understand if the embedded client is correct for you.
95
+ By default the latest and greatest version of the Elasticsearch client is used, see the [compatibility](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/introduction.html#_compatibility) table to understand if the embedded client is correct for you.
82
96
  If it is not, you can pass a custom client via the `client` option.
83
97
  ```js
84
98
  const fastify = require('fastify')()
package/es-docker.sh CHANGED
@@ -8,4 +8,4 @@ exec docker run \
8
8
  -e "discovery.type=single-node" \
9
9
  -e "xpack.security.enabled=false" \
10
10
  -p 9200:9200 \
11
- docker.elastic.co/elasticsearch/elasticsearch:8.3.2
11
+ docker.elastic.co/elasticsearch/elasticsearch:8.15.2
@@ -0,0 +1,6 @@
1
+ 'use strict'
2
+
3
+ module.exports = require('neostandard')({
4
+ ignores: require('neostandard').resolveIgnoresFromGitignore(),
5
+ ts: true
6
+ })
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@fastify/elasticsearch",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Fastify plugin for elastic search",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
7
7
  "types": "types/index.d.ts",
8
8
  "scripts": {
9
- "lint": "standard",
9
+ "lint": "eslint",
10
+ "lint:fix": "eslint --fix",
10
11
  "test": "npm run test:unit && npm run test:typescript",
11
- "test:unit": "tap",
12
+ "test:unit": "c8 --100 node --test",
12
13
  "test:typescript": "tsd"
13
14
  },
14
15
  "repository": {
@@ -23,21 +24,51 @@
23
24
  "ES"
24
25
  ],
25
26
  "author": "Tommaso Allevi - @allevo",
27
+ "contributors": [
28
+ {
29
+ "name": "Matteo Collina",
30
+ "email": "hello@matteocollina.com"
31
+ },
32
+ {
33
+ "name": "James Sumners",
34
+ "url": "https://james.sumners.info"
35
+ },
36
+ {
37
+ "name": "Tomas Della Vedova",
38
+ "url": "http://delved.org"
39
+ },
40
+ {
41
+ "name": "Frazer Smith",
42
+ "email": "frazer.dev@icloud.com",
43
+ "url": "https://github.com/fdawgs"
44
+ }
45
+ ],
26
46
  "license": "MIT",
27
47
  "bugs": {
28
48
  "url": "https://github.com/fastify/fastify-elasticsearch/issues"
29
49
  },
30
50
  "homepage": "https://github.com/fastify/fastify-elasticsearch#readme",
51
+ "funding": [
52
+ {
53
+ "type": "github",
54
+ "url": "https://github.com/sponsors/fastify"
55
+ },
56
+ {
57
+ "type": "opencollective",
58
+ "url": "https://opencollective.com/fastify"
59
+ }
60
+ ],
31
61
  "dependencies": {
32
62
  "@elastic/elasticsearch": "^8.13.1",
33
63
  "fastify-plugin": "^5.0.0"
34
64
  },
35
65
  "devDependencies": {
36
- "@types/node": "^22.0.0",
37
66
  "@fastify/pre-commit": "^2.1.0",
38
- "fastify": "^5.0.0-alpha.4",
39
- "standard": "^17.1.0",
40
- "tap": "^18.7.2",
67
+ "@types/node": "^22.0.0",
68
+ "c8": "^10.1.2",
69
+ "eslint": "^9.17.0",
70
+ "fastify": "^5.0.0",
71
+ "neostandard": "^0.12.0",
41
72
  "tsd": "^0.31.0"
42
73
  },
43
74
  "publishConfig": {
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { test } = require('tap')
3
+ const { test } = require('node:test')
4
4
  const { Client } = require('@elastic/elasticsearch')
5
5
  const Fastify = require('fastify')
6
6
  const fastifyElasticsearch = require('..')
@@ -8,29 +8,29 @@ const isElasticsearchClient = require('..').isElasticsearchClient
8
8
 
9
9
  test('with reachable cluster', async t => {
10
10
  const fastify = Fastify()
11
- t.teardown(() => fastify.close())
11
+ t.after(() => fastify.close())
12
12
  fastify.register(fastifyElasticsearch, { node: 'http://localhost:9200' })
13
13
 
14
14
  await fastify.ready()
15
- t.equal(fastify.elastic.name, 'elasticsearch-js')
15
+ t.assert.equal(fastify.elastic.name, 'elasticsearch-js')
16
16
  })
17
17
 
18
18
  test('with unreachable cluster', async t => {
19
19
  const fastify = Fastify()
20
- t.teardown(() => fastify.close())
20
+ t.after(() => fastify.close())
21
21
  fastify.register(fastifyElasticsearch, { node: 'http://localhost:9201' })
22
22
 
23
23
  try {
24
24
  await fastify.ready()
25
- t.fail('should not boot successfully')
25
+ t.assert.fail('should not boot successfully')
26
26
  } catch (err) {
27
- t.ok(err)
27
+ t.assert.ok(err)
28
28
  }
29
29
  })
30
30
 
31
31
  test('with unreachable cluster and healthcheck disabled', async t => {
32
32
  const fastify = Fastify()
33
- t.teardown(() => fastify.close())
33
+ t.after(() => fastify.close())
34
34
  fastify.register(fastifyElasticsearch, {
35
35
  node: 'http://localhost:9201',
36
36
  healthcheck: false
@@ -38,30 +38,30 @@ test('with unreachable cluster and healthcheck disabled', async t => {
38
38
 
39
39
  try {
40
40
  await fastify.ready()
41
- t.equal(fastify.elastic.name, 'elasticsearch-js')
42
- } catch (err) {
43
- t.fail('should not error')
41
+ t.assert.equal(fastify.elastic.name, 'elasticsearch-js')
42
+ } catch {
43
+ t.assert.fail('should not error')
44
44
  }
45
45
  })
46
46
 
47
47
  test('namespaced', async t => {
48
48
  const fastify = Fastify()
49
- t.teardown(() => fastify.close())
49
+ t.after(() => fastify.close())
50
50
  fastify.register(fastifyElasticsearch, {
51
51
  node: 'http://localhost:9200',
52
52
  namespace: 'cluster'
53
53
  })
54
54
 
55
55
  await fastify.ready()
56
- t.equal(fastify.elastic.cluster.name, 'elasticsearch-js')
57
- t.equal(isElasticsearchClient(fastify.elastic), false)
58
- t.equal(isElasticsearchClient(fastify.elastic.cluster), true)
56
+ t.assert.equal(fastify.elastic.cluster.name, 'elasticsearch-js')
57
+ t.assert.equal(isElasticsearchClient(fastify.elastic), false)
58
+ t.assert.equal(isElasticsearchClient(fastify.elastic.cluster), true)
59
59
  await fastify.close()
60
60
  })
61
61
 
62
62
  test('namespaced (errored)', async t => {
63
63
  const fastify = Fastify()
64
- t.teardown(() => fastify.close())
64
+ t.after(() => fastify.close())
65
65
  fastify.register(fastifyElasticsearch, {
66
66
  node: 'http://localhost:9200',
67
67
  namespace: 'cluster'
@@ -74,9 +74,9 @@ test('namespaced (errored)', async t => {
74
74
 
75
75
  try {
76
76
  await fastify.ready()
77
- t.fail('should not boot successfully')
77
+ t.assert.fail('should not boot successfully')
78
78
  } catch (err) {
79
- t.ok(err)
79
+ t.assert.ok(err)
80
80
  }
81
81
  })
82
82
 
@@ -87,24 +87,24 @@ test('custom client', async t => {
87
87
  })
88
88
 
89
89
  const fastify = Fastify()
90
- t.teardown(() => fastify.close())
90
+ t.after(() => fastify.close())
91
91
  fastify.register(fastifyElasticsearch, { client })
92
92
 
93
93
  await fastify.ready()
94
- t.equal(isElasticsearchClient(fastify.elastic), true)
95
- t.equal(fastify.elastic.name, 'custom')
94
+ t.assert.equal(isElasticsearchClient(fastify.elastic), true)
95
+ t.assert.equal(fastify.elastic.name, 'custom')
96
96
  await fastify.close()
97
97
  })
98
98
 
99
99
  test('Missing configuration', async t => {
100
100
  const fastify = Fastify()
101
- t.teardown(() => fastify.close())
101
+ t.after(() => fastify.close())
102
102
  fastify.register(fastifyElasticsearch)
103
103
 
104
104
  try {
105
105
  await fastify.ready()
106
- t.fail('should not boot successfully')
106
+ t.assert.fail('should not boot successfully')
107
107
  } catch (err) {
108
- t.ok(err)
108
+ t.assert.ok(err)
109
109
  }
110
110
  })
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { FastifyPluginAsync } from 'fastify';
2
- import type { Client, ClientOptions } from '@elastic/elasticsearch';
1
+ import type { FastifyPluginAsync } from 'fastify'
2
+ import type { Client, ClientOptions } from '@elastic/elasticsearch'
3
3
 
4
4
  declare module 'fastify' {
5
5
  interface FastifyInstance {
@@ -23,5 +23,5 @@ declare namespace fastifyElasticsearch {
23
23
  export { fastifyElasticsearch as default }
24
24
  }
25
25
 
26
- declare function fastifyElasticsearch(...params: Parameters<FastifyElasticsearch>): ReturnType<FastifyElasticsearch>
26
+ declare function fastifyElasticsearch (...params: Parameters<FastifyElasticsearch>): ReturnType<FastifyElasticsearch>
27
27
  export = fastifyElasticsearch
@@ -1,8 +1,7 @@
1
- import fastifyElasticsearch from '..';
2
- import Fastify from 'fastify';
3
- import { expectAssignable, expectType } from 'tsd';
4
- import { Client } from '@elastic/elasticsearch';
5
-
1
+ import fastifyElasticsearch from '..'
2
+ import Fastify from 'fastify'
3
+ import { expectAssignable, expectType } from 'tsd'
4
+ import { Client } from '@elastic/elasticsearch'
6
5
 
7
6
  const fastify = Fastify()
8
7
  fastify.register(fastifyElasticsearch, { node: 'http://localhost:9200' })
package/.taprc DELETED
@@ -1,2 +0,0 @@
1
- files:
2
- - test/**/*.test.js