diff --git a/README.md b/README.md index adb65d3..02598d4 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,15 @@ Analyze text with Aalyzer ![Sample image](docs/sample_image.jpg) +This branch is for Kibana 7.x. + ## How to use? See [Getting Started](docs/GETTING_STARTED.md) ## Installation -The latest version is for kibana 6.5.0. +The latest stable version is for kibana 6.5.0. +The latest alpha version is for kibana 7.0.0-alpha1 | Kibana version | Command | | ---------- | ------- | diff --git a/package.json b/package.json index 8715877..4ba0667 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "analyze-api-ui-plugin", - "version": "6.5.0", + "version": "7.0.0-alpha1", "description": "UI for elasticsearch analyze API", "main": "index.js", "kibana": { - "version": "6.5.0", + "version": "7.0.0-alpha1", "templateVersion": "1.0.0" }, "scripts": { @@ -19,21 +19,21 @@ "dependencies": { "boom": "2.8.0", "joi": "6.10.1", - "lodash": "4.17.5" + "lodash": "4.17.11" }, "devDependencies": { "@elastic/eslint-config-kibana": "link:../../kibana/packages/eslint-config-kibana", "@elastic/eslint-import-resolver-kibana": "link:../../kibana/packages/kbn-eslint-import-resolver-kibana", "@kbn/plugin-helpers": "link:../../kibana/packages/kbn-plugin-helpers", - "babel-eslint": "^8.0.2", - "eslint": "^4.11.0", - "eslint-plugin-babel": "^4.1.1", - "eslint-plugin-import": "^2.3.0", - "eslint-plugin-jest": "^21.3.2", - "eslint-plugin-mocha": "^4.9.0", + "babel-eslint": "^9.0.0", + "eslint": "^5.6.0", + "eslint-plugin-babel": "^5.2.0", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-jest": "^21.22.1", + "eslint-plugin-mocha": "^5.2.0", "eslint-plugin-no-unsanitized": "^3.0.2", "eslint-plugin-prefer-object-spread": "^1.2.1", - "eslint-plugin-react": "^7.0.1", + "eslint-plugin-react": "^7.11.1", "expect.js": "^0.3.1" } } diff --git a/server/routes/analyze.js b/server/routes/analyze.js index d1015f8..8fc9404 100644 --- a/server/routes/analyze.js +++ b/server/routes/analyze.js @@ -8,7 +8,7 @@ export default function (server) { server.route({ path: '/api/analyze-api-ui-plugin/analyze', method: 'POST', - config: { + options: { validate: { payload: Joi.object().keys({ text: Joi.string().required(), @@ -21,7 +21,7 @@ export default function (server) { }).required() } }, - handler(req, reply) { + handler: async (req) => { // get params from req // call _analyze api @@ -37,24 +37,22 @@ export default function (server) { if (req.payload.charfilters) param.body.char_filter = req.payload.charfilters; if (req.payload.field) param.body.field = req.payload.field; if (req.payload.filters) param.body.filter = req.payload.filters; - call(req, 'indices.analyze', param) - .then(function (response) { - let res = { - detail: response.detail, - request: param.body - } - reply(res); - }) - .catch(error => { - reply(convertEsError(param.index, error)); - }); + try { + const response = await call(req, 'indices.analyze', param); + return { + detail: response.detail, + request: param.body + }; + } catch (error) { + return convertEsError(param.index, error); + } } }); server.route({ path: '/api/analyze-api-ui-plugin/multi_analyze', method: 'POST', - config: { + options: { validate: { payload: Joi.object().keys({ text: Joi.string().required(), @@ -66,7 +64,7 @@ export default function (server) { }).required() } }, - handler(req, reply) { + handler: async (req, h) => { // get params from req // call _analyze api @@ -106,13 +104,13 @@ export default function (server) { return 0; } ); - reply(res); + return h.response(res); }) .catch(error => { - reply(convertEsError(param.index, error)); + return h.response(convertEsError(param.index, error)); }); } else { - reply(res); + return h.response(res); } } });