From 10c5dd81b0c0219d8a7c513bb64c5578e88c2ea7 Mon Sep 17 00:00:00 2001 From: Pedro Pereira Date: Mon, 28 May 2018 11:29:54 +0100 Subject: [PATCH 1/3] [MAJOR 1.0.0][BREAKING-CHANGES] - Removed services module. Remove submodules configuration (now its 1 level only). --- CHANGELOG.md | 7 +++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d04eb01..83ef26e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +# [1.0.0](https://github.com/ezypeeze/nuxt-neo/compare/v0.0.5...v1.0.0) (2018-05-28) +- Removed Services Module +- Removed submodules configuration. +- This package will take care only of the API initialization and access both from client and server side +- Updated documentation + ## [0.0.4](https://github.com/ezypeeze/nuxt-neo/compare/v0.0.3...v0.0.4) (2018-05-26) - Services are disabled by default diff --git a/package-lock.json b/package-lock.json index 2c2fee4..202fce8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "nuxt-neo", - "version": "0.0.4", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 430b3cd..df7054d 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nuxt-neo", - "version": "0.0.4", + "version": "1.0.0", "description": "A nuxt.js module that implements a universal api layer, same-way compatible between server and client side.", "keywords": [ "nuxt", From ba06cdfb97d729cf350a21b11f78b7f83790e936 Mon Sep 17 00:00:00 2001 From: Pedro Pereira Date: Mon, 28 May 2018 12:27:09 +0100 Subject: [PATCH 2/3] fix: fixed docs basic-usage.md (add two 'export default' on client side api handler example) --- docs/basic-usage.md | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/docs/basic-usage.md b/docs/basic-usage.md index e74e598..4ba7d37 100644 --- a/docs/basic-usage.md +++ b/docs/basic-usage.md @@ -96,24 +96,20 @@ Lets create our handler now (e.g we using axios to take care of this for us): // file: ~/api_handler import axios from 'axios'; -export default () { - - // path is the relative path of the route - // verb is the method type - // {query, body, params} are the given payload to send - // {prefix} are api options (prefix is the api prefix, e.g: '/api') - export default (path, verb, {query, body}, {prefix}) => { - return axios({ - baseURL: `http://${process.env.HOST}:${process.env.PORT}${prefix || ''}`, - timeout: 10000, - url: path, - method: verb.toLowerCase(), - data: body, - params: query - }).then(({data}) => data); - }; - -} +// path is the relative path of the route +// verb is the method type +// {query, body, params} are the given payload to send +// {prefix} are api options (prefix is the api prefix, e.g: '/api') +export default (path, verb, {query, body}, {prefix}) => { + return axios({ + baseURL: `http://${process.env.HOST}:${process.env.PORT}${prefix || ''}`, + timeout: 10000, + url: path, + method: verb.toLowerCase(), + data: body, + params: query + }).then(({data}) => data); +}; ``` **NOTE**: You must return exactly what the controller action + ```successHandler``` return, From 17b1974b3848aa705d32e896a7fad500c552be03 Mon Sep 17 00:00:00 2001 From: Pedro Pereira Date: Mon, 28 May 2018 13:12:02 +0100 Subject: [PATCH 3/3] fix: error response handler handles now the proper error, instead of moving to nuxt error handling. --- lib/server_middleware/api.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/server_middleware/api.js b/lib/server_middleware/api.js index 20e791c..900b302 100755 --- a/lib/server_middleware/api.js +++ b/lib/server_middleware/api.js @@ -117,9 +117,12 @@ function injectAPI(options) { // Error Response handler router.use(function (err, req, res, next) { - return Promise.resolve(options.errorHandler(err, req)) - .then(_err => options.errorResponse(_err || err, req, res, options)) - .catch(_err => options.errorResponse(_err, req, res, options)) + try { + Promise.resolve(options.errorHandler(err, req)) + .then(_err => options.errorResponse(_err || err, req, res, options)); + } catch (_err) { + options.errorResponse(_err, req, res, options); + } }); return {