Skip to content

Commit

Permalink
- Changed standard Linter to semistandard
Browse files Browse the repository at this point in the history
- Added TypeScript definition file
- Added more info in README on materialized views
- Bumped version to 3.4.1
  • Loading branch information
Dekel Barzilay committed Feb 1, 2020
1 parent 5cd0bfe commit 0c1f21d
Show file tree
Hide file tree
Showing 28 changed files with 4,367 additions and 2,130 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,22 @@ app.service('/user-todos').get([1, 2])
app.service('/user-todos').get({ userId: 1, todoId: 2 })
```
* **`materializedViews`** - (optional) array of materialized views to use when queries contains the same set of columns that constructs their compound PK.
```js
app.use('/players', service({
materializedViews: [
{
view: 'top_season_players',
keys: [
'season',
'score'
]
}
]
})
```
## Complete Example
Here's a complete example of a Feathers server with a `todos` Feathers-Cassandra service:
Expand Down
3,469 changes: 2,816 additions & 653 deletions package-lock.json

Large diffs are not rendered by default.

29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "feathers-cassandra",
"description": "Feathers service adapter for Cassandra DB based on Express-Cassandra ORM and CassanKnex query builder",
"version": "3.4.0",
"version": "3.4.1",
"homepage": "https://github.com/dekelev/feathers-cassandra",
"keywords": [
"feathers",
Expand Down Expand Up @@ -36,16 +36,18 @@
],
"scripts": {
"prepare": "npm run compile",
"publish": "git push origin && git push origin --tags",
"publish": "git push origin --tags && npm run changelog && git push origin",
"changelog": "github_changelog_generator && git add CHANGELOG.md && git commit -am \"Updating changelog\"",
"release:patch": "npm version patch && npm publish",
"release:minor": "npm version minor && npm publish",
"release:major": "npm version major && npm publish",
"compile": "rimraf lib/ && babel -d lib/ src/",
"watch": "babel --watch -d lib/ src/",
"lint": "standard --fix src/**/*.js test/**/*.js --config",
"lint": "semistandard --fix src/**/*.js test/**/*.js --config",
"dtslint": "dtslint --localTs node_modules/typescript/lib types",
"mocha": "nyc mocha --opts mocha.opts",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"test": "npm run compile && npm run lint && npm run mocha",
"test": "npm run compile && npm run lint && npm run dtslint && npm run mocha",
"example": "npm run compile && babel-node example/app"
},
"directories": {
Expand All @@ -58,13 +60,14 @@
"lodash.isequal": "^4.5.0"
},
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/preset-env": "^7.7.5",
"@babel/register": "^7.7.4",
"@feathersjs/adapter-tests": "^4.4.1",
"@feathersjs/express": "^4.4.1",
"@feathersjs/feathers": "^4.4.1",
"@babel/cli": "^7.7.7",
"@babel/core": "^7.7.7",
"@babel/preset-env": "^7.7.7",
"@babel/node": "^7.7.7",
"@babel/register": "^7.7.7",
"@feathersjs/adapter-tests": "^4.4.3",
"@feathersjs/express": "^4.4.3",
"@feathersjs/feathers": "^4.4.3",
"await-sleep": "0.0.1",
"babel-eslint": "^10.0.3",
"babel-plugin-add-module-exports": "^1.0.2",
Expand All @@ -82,7 +85,7 @@
"request": "^2.88.0",
"request-promise": "^4.2.5",
"rimraf": "^3.0.0",
"standard": "^14.3.1"
"semistandard": "^14.2.0"
},
"peerDependencies": {
"express-cassandra": "*"
Expand Down Expand Up @@ -111,7 +114,7 @@
"example/**"
]
},
"standard": {
"semistandard": {
"parser": "babel-eslint",
"env": [
"mocha"
Expand Down
68 changes: 34 additions & 34 deletions src/error-handler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const errors = require('@feathersjs/errors')
const errors = require('@feathersjs/errors');

const ERROR = Symbol('feathers-knex/error')
const ERROR = Symbol('feathers-knex/error');
const ERROR_CODES = {
serverError: 0x0000,
protocolError: 0x000A,
Expand All @@ -20,79 +20,79 @@ const ERROR_CODES = {
configError: 0x2300,
alreadyExists: 0x2400,
unprepared: 0x2500
}
};

module.exports = function errorHandler (error) {
const { message } = error
let feathersError = error
const { message } = error;
let feathersError = error;

if (error instanceof TypeError) {
feathersError = new errors.BadRequest(message)
feathersError = new errors.BadRequest(message);
} else if (!(error instanceof errors.FeathersError)) {
if (error.code !== undefined) { // CassanKnex errors
switch (error.code) {
case ERROR_CODES.syntaxError:
case ERROR_CODES.invalid:
case ERROR_CODES.truncateError:
feathersError = new errors.BadRequest(message)
break
feathersError = new errors.BadRequest(message);
break;

case ERROR_CODES.badCredentials:
feathersError = new errors.NotAuthenticated(message)
break
feathersError = new errors.NotAuthenticated(message);
break;

case ERROR_CODES.unauthorized:
feathersError = new errors.Forbidden(message)
break
feathersError = new errors.Forbidden(message);
break;

case ERROR_CODES.functionFailure:
feathersError = new errors.MethodNotAllowed(message)
break
feathersError = new errors.MethodNotAllowed(message);
break;

case ERROR_CODES.protocolError:
feathersError = new errors.NotAcceptable(message)
break
feathersError = new errors.NotAcceptable(message);
break;

case ERROR_CODES.readTimeout:
case ERROR_CODES.writeTimeout:
feathersError = new errors.Timeout(message)
break
feathersError = new errors.Timeout(message);
break;

case ERROR_CODES.alreadyExists:
feathersError = new errors.Conflict(message)
break
feathersError = new errors.Conflict(message);
break;

case ERROR_CODES.overloaded:
feathersError = new errors.Unprocessable(message)
break
feathersError = new errors.Unprocessable(message);
break;

case ERROR_CODES.configError:
case ERROR_CODES.serverError:
case ERROR_CODES.readFailure:
case ERROR_CODES.writeFailure:
feathersError = new errors.GeneralError(message)
break
feathersError = new errors.GeneralError(message);
break;

case ERROR_CODES.unprepared:
feathersError = new errors.NotImplemented(message)
break
feathersError = new errors.NotImplemented(message);
break;

case ERROR_CODES.isBootstrapping:
case ERROR_CODES.unavailableException:
feathersError = new errors.Unavailable(message)
break
feathersError = new errors.Unavailable(message);
break;

default:
feathersError = new errors.GeneralError(message)
feathersError = new errors.GeneralError(message);
}
} else {
feathersError = new errors.GeneralError(message)
feathersError = new errors.GeneralError(message);
}
}

feathersError[ERROR] = error
feathersError[ERROR] = error;

throw feathersError
}
throw feathersError;
};

module.exports.ERROR = ERROR
module.exports.ERROR = ERROR;
Loading

0 comments on commit 0c1f21d

Please sign in to comment.