|
1 | | -const { instantMeiliSearch } = require('@meilisearch/instant-meilisearch') |
2 | | -const { MeiliSearch } = require('meilisearch') |
| 1 | +import { instantMeiliSearch } from '@meilisearch/instant-meilisearch'; |
| 2 | +import { MeiliSearch } from 'meilisearch'; |
3 | 3 |
|
| 4 | +const { searchClient } = instantMeiliSearch( |
| 5 | + 'http://localhost:7700', |
| 6 | + 'masterKey', |
| 7 | + {}, |
| 8 | +); |
| 9 | +const msClient = new MeiliSearch({ |
| 10 | + host: 'http://localhost:7700', |
| 11 | + apiKey: 'masterKey', |
| 12 | +}); |
4 | 13 |
|
5 | | -const { searchClient } = instantMeiliSearch('http://localhost:7700', 'masterKey', {}) |
6 | | -const msClient = new MeiliSearch({ host: 'http://localhost:7700', apiKey: 'masterKey'}) |
| 14 | +try { |
| 15 | + const task1 = await msClient.index('node_test').addDocuments([]); |
| 16 | + await msClient.waitForTask(task1.taskUid); |
| 17 | + await searchClient.search([ |
| 18 | + { |
| 19 | + indexName: 'node_test', |
| 20 | + params: { |
| 21 | + query: '', |
| 22 | + }, |
| 23 | + }, |
| 24 | + ]); |
7 | 25 |
|
8 | | -;(async() => { |
9 | | - try { |
10 | | - const task1 = await msClient.index('node_test').addDocuments([]) |
11 | | - await msClient.waitForTask(task1.taskUid) |
12 | | - await searchClient.search([ |
13 | | - { |
14 | | - indexName: 'node_test', |
15 | | - params: { |
16 | | - query: '', |
17 | | - }, |
18 | | - } |
19 | | - ]) |
20 | | - |
21 | | - const task2 = await msClient.index('node_test').delete() |
22 | | - await msClient.waitForTask(task2.taskUid) |
23 | | - process.exit(0) |
24 | | - } catch(e) { |
25 | | - console.log(e) |
26 | | - console.error('Could not run the `umd` build in a node environment') |
27 | | - process.exit(1) |
28 | | - } |
29 | | -})() |
| 26 | + const task2 = await msClient.index('node_test').delete(); |
| 27 | + await msClient.waitForTask(task2.taskUid); |
| 28 | + process.exit(0); |
| 29 | +} catch (e) { |
| 30 | + console.log(e); |
| 31 | + console.error('Could not run the `umd` build in a node environment'); |
| 32 | + process.exit(1); |
| 33 | +} |
0 commit comments