Skip to content

Commit 1808f91

Browse files
authored
Improve example and readme's (#517)
End of file line Editorconfig enabled Linting and fixes Spacing Update examples/typescript-browser/README.md Co-authored-by: Clémentine Urquizar <[email protected]> Update examples/typescript-browser/README.md Co-authored-by: Clémentine Urquizar <[email protected]> Update examples/typescript-node/README.md Co-authored-by: Clémentine Urquizar <[email protected]> Update examples/typescript-node/README.md Improve wording
1 parent 3902964 commit 1808f91

File tree

8 files changed

+131
-6
lines changed

8 files changed

+131
-6
lines changed

examples/browser/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Browser demo
2+
3+
## Requirements
4+
5+
Build the base project `/meilisearch-js` as this example uses the locally build bundles from `meilisearch-js`.
6+
7+
```
8+
$ cd meilisearch-js
9+
$ yarn build
10+
```
11+
12+
## Credentials
13+
14+
This example uses the following MeiliSearch address: `http://127.0.0.1:7700`. Feel free to change the credentials to meet your MeiliSearch address.
15+
16+
The credentials are written in `index.html`.
17+
18+
## Try out
19+
20+
To try out this html file, just open it using any browser.

examples/browser/webpage.html renamed to examples/browser/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@
77
<meta name='viewport' content='width=device-width, initial-scale=1'>
88
</head>
99
<body>
10-
hello
10+
Indexes:
11+
<div id="indexes"></div>
1112
</body>
1213
</html>
13-
<script src="../../dist/bundles/meilisearch.umd.js"></script>
14+
<script src="../../dist/bundles/meilisearch.browser.js"></script>
1415
<script>
15-
const client = new window.Meiliearch({
16+
const client = new window.MeiliSearch({
1617
host: 'http://127.0.0.1:7700',
1718
apiKey: 'masterKey',
1819
})
1920
client.listIndexes().then(res => {
2021
console.log({ res });
22+
res.map(index => document.querySelector('#indexes').innerHTML = `<div>${index.name}</div>`)
2123
})
2224
</script>

examples/node/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Node demo
2+
3+
## Requirements
4+
5+
Build the base project `/meilisearch-js` as this example uses the locally build bundles from `meilisearch-js`.
6+
7+
```
8+
$ cd meilisearch-js
9+
$ yarn build
10+
```
11+
12+
## Credentials
13+
14+
This example uses the following MeiliSearch address: `http://127.0.0.1:7700`. Feel free to change the credentials to meet your MeiliSearch address.
15+
16+
The credentials are written in each script.
17+
18+
## Try out
19+
20+
To try it out you just need to execute the script that you want to try out.
21+
22+
For example:
23+
```
24+
node search_example.js
25+
```

examples/node/search_example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const MeiliSearch = require('../../')
1+
const MeiliSearch = require('../../dist/bundles/meilisearch.cjs.js')
22
const dataset = require('./small_movies.json')
33

44
const config = {

examples/node/small_index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const MeiliSearch = require('../../')
1+
const MeiliSearch = require('../../dist/bundles/meilisearch.cjs.js')
22

33
const config = {
44
host: 'http://127.0.0.1:7700',
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# TypeScript React demo
2+
3+
## Requirements
4+
5+
Build the base project `/meilisearch-js` as this example uses the locally build bundles from `meilisearch-js`.
6+
7+
```
8+
$ cd meilisearch-js
9+
$ yarn build
10+
```
11+
12+
## Credentials
13+
14+
This example uses the following MeiliSearch address: `http://127.0.0.1:7700`. Feel free to change the credentials to meet your MeiliSearch address.
15+
16+
The credentials are written in `src/index.ts`.
17+
18+
## Try out
19+
20+
To try it out you need to follow these steps.
21+
22+
### 1. Install dependencies
23+
24+
```bash
25+
$ yarn
26+
```
27+
28+
### 2. Build
29+
30+
```bash
31+
$ yarn build
32+
```
33+
34+
### 3. Serve
35+
36+
```bash
37+
$ http-server public
38+
```
39+
40+
We used http-server CLI to serve the webpage. Feel free to use any tool with the same purpose as it will not impact the result.

examples/typescript-browser/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ function greeter(person: string) {
1818
const uids = indexes.map((index: IndexResponse) => index.uid)
1919
document.body.innerHTML = `${greeter(
2020
user
21-
)} this is the list of all your indexes: ${uids.join(', ')}`
21+
)} this is the list of all your indexes: \n ${uids.join(', ')}`
2222
})()

examples/typescript-node/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# TypeScript Node demo
2+
3+
## Requirements
4+
5+
Build the base project `/meilisearch-js` as this example uses the locally build bundles from `meilisearch-js`.
6+
7+
```
8+
$ cd meilisearch-js
9+
$ yarn build
10+
```
11+
12+
## Credentials
13+
14+
This example uses the following MeiliSearch address: `http://127.0.0.1:7700`. Feel free to change the credentials to meet your MeiliSearch address.
15+
16+
The credentials are written in `src/index.ts`.
17+
18+
## Try out
19+
20+
To try it out you need to follow these steps:
21+
22+
### 1. Install dependencies
23+
24+
```bash
25+
$ yarn
26+
```
27+
28+
### 2. Build
29+
30+
```bash
31+
$ yarn build
32+
```
33+
34+
### 3. Execute
35+
36+
```bash
37+
$ node build/bundle.js
38+
```

0 commit comments

Comments
 (0)