Skip to content

Commit 2879369

Browse files
committed
Fix Node.js playground
1 parent 07edb2b commit 2879369

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed

playgrounds/node-env/index.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
const { instantMeiliSearch } = require('@meilisearch/instant-meilisearch')
2-
const { MeiliSearch } = require('meilisearch')
1+
import { instantMeiliSearch } from '@meilisearch/instant-meilisearch';
2+
import { MeiliSearch } from 'meilisearch';
33

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+
});
413

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+
]);
725

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+
}

playgrounds/node-env/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"version": "0.0.0",
44
"private": true,
55
"description": "Instant-meilisearch playground written in node",
6-
"main": "index.js",
6+
"type": "module",
7+
"exports": {
8+
".": "./index.js"
9+
},
710
"scripts": {
811
"dev": "node index.js"
912
},

0 commit comments

Comments
 (0)