Skip to content

Commit d35a9b8

Browse files
committed
[WIP] Upgrade 7.0.0-alpha1
* Fixed upgrade Hapi 17, still need to fix comparing analyzer results * Need to fix requesting to Rest API
1 parent 36085d4 commit d35a9b8

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
Analyze text with Aalyzer
66
![Sample image](docs/sample_image.jpg)
77

8+
This branch is for Kibana 7.x.
9+
810
## How to use?
911

1012
See [Getting Started](docs/GETTING_STARTED.md)
1113

1214
## Installation
13-
The latest version is for kibana 6.5.0.
15+
The latest stable version is for kibana 6.5.0.
16+
The latest alpha version is for kibana 7.0.0-alpha1
1417

1518
| Kibana version | Command |
1619
| ---------- | ------- |

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "analyze-api-ui-plugin",
3-
"version": "6.5.0",
3+
"version": "7.0.0-alpha1",
44
"description": "UI for elasticsearch analyze API",
55
"main": "index.js",
66
"kibana": {
7-
"version": "6.5.0",
7+
"version": "7.0.0-alpha1",
88
"templateVersion": "1.0.0"
99
},
1010
"scripts": {
@@ -25,15 +25,15 @@
2525
"@elastic/eslint-config-kibana": "link:../../kibana/packages/eslint-config-kibana",
2626
"@elastic/eslint-import-resolver-kibana": "link:../../kibana/packages/kbn-eslint-import-resolver-kibana",
2727
"@kbn/plugin-helpers": "link:../../kibana/packages/kbn-plugin-helpers",
28-
"babel-eslint": "^8.0.2",
29-
"eslint": "^4.11.0",
30-
"eslint-plugin-babel": "^4.1.1",
31-
"eslint-plugin-import": "^2.3.0",
32-
"eslint-plugin-jest": "^21.3.2",
33-
"eslint-plugin-mocha": "^4.9.0",
28+
"babel-eslint": "^9.0.0",
29+
"eslint": "^5.6.0",
30+
"eslint-plugin-babel": "^5.2.0",
31+
"eslint-plugin-import": "^2.14.0",
32+
"eslint-plugin-jest": "^21.22.1",
33+
"eslint-plugin-mocha": "^5.2.0",
3434
"eslint-plugin-no-unsanitized": "^3.0.2",
3535
"eslint-plugin-prefer-object-spread": "^1.2.1",
36-
"eslint-plugin-react": "^7.0.1",
36+
"eslint-plugin-react": "^7.11.1",
3737
"expect.js": "^0.3.1"
3838
}
3939
}

server/routes/analyze.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function (server) {
88
server.route({
99
path: '/api/analyze-api-ui-plugin/analyze',
1010
method: 'POST',
11-
config: {
11+
options: {
1212
validate: {
1313
payload: Joi.object().keys({
1414
text: Joi.string().required(),
@@ -21,7 +21,7 @@ export default function (server) {
2121
}).required()
2222
}
2323
},
24-
handler(req, reply) {
24+
handler: async (req) => {
2525

2626
// get params from req
2727
// call _analyze api
@@ -37,24 +37,22 @@ export default function (server) {
3737
if (req.payload.charfilters) param.body.char_filter = req.payload.charfilters;
3838
if (req.payload.field) param.body.field = req.payload.field;
3939
if (req.payload.filters) param.body.filter = req.payload.filters;
40-
call(req, 'indices.analyze', param)
41-
.then(function (response) {
42-
let res = {
43-
detail: response.detail,
44-
request: param.body
45-
}
46-
reply(res);
47-
})
48-
.catch(error => {
49-
reply(convertEsError(param.index, error));
50-
});
40+
try {
41+
const response = await call(req, 'indices.analyze', param);
42+
return {
43+
detail: response.detail,
44+
request: param.body
45+
};
46+
} catch (error) {
47+
return convertEsError(param.index, error);
48+
}
5149
}
5250
});
5351

5452
server.route({
5553
path: '/api/analyze-api-ui-plugin/multi_analyze',
5654
method: 'POST',
57-
config: {
55+
options: {
5856
validate: {
5957
payload: Joi.object().keys({
6058
text: Joi.string().required(),
@@ -66,7 +64,7 @@ export default function (server) {
6664
}).required()
6765
}
6866
},
69-
handler(req, reply) {
67+
handler: async (req, h) => {
7068

7169
// get params from req
7270
// call _analyze api
@@ -106,13 +104,13 @@ export default function (server) {
106104
return 0;
107105
}
108106
);
109-
reply(res);
107+
return h.response(res);
110108
})
111109
.catch(error => {
112-
reply(convertEsError(param.index, error));
110+
return h.response(convertEsError(param.index, error));
113111
});
114112
} else {
115-
reply(res);
113+
return h.response(res);
116114
}
117115
}
118116
});

0 commit comments

Comments
 (0)