Questions tagged [feathers-hook]

setting hooks or writing hook functions for the Feathers framework

What it is?

Hooks are functions that are transport independent and that can be set to be called before, after, or on error of a service method, for extending the behavior of the service, for example, validating, logging, sending notifications etc.

How if works?

Several hook functions can be registered for the same event. Upon occurence, the hook functions are chained and called in the order of their registration.

See also

55 questions
11
votes
2 answers

Why after upgrade feathersjs I receive error: MethodNotAllowed

I upgraded my feathersjs version from 2.x.x to 3.9.0 Now I have a problem with hooks (after) this is my query: app.service('duties').patch(id, { $set: { status: 0 }}, {}); I have below code in my hook after: var query = { "duties._id": result._id…
SeaDog
  • 645
  • 1
  • 9
  • 32
3
votes
0 answers

Ordering query with feathers-sequelize

I am trying to write a hook which adds ordering to a query on a table with associations. My query is on 'points' which has a join-table 'point_photos' and then is associated m:n to 'photos'. The standard feathersjs $sort can not be used for…
musicformellons
  • 12,283
  • 4
  • 51
  • 86
2
votes
1 answer

Add a custom query parameter in Feathers request

I'm hoping to add a custom query parameter that can be used in a hook to process some results. I'd like to add $foo=bar to the request. I can whitelist $foo and it appears in the request, but the service is using an ORM so it tries to query the…
Steven Sokulski
  • 354
  • 1
  • 4
  • 17
2
votes
1 answer

Using feathers-client and sequelize many-to-many relation

I'm trying to get data from an n:m association using feathers. I'm using react for my front-end and connecting to feathers using the feathers-client and socketio. //connection string where the feathers api is running const host =…
theVortr3x
  • 70
  • 10
2
votes
1 answer

To update single field in a document on MongoDB, what is the best method? update or patch hook in feathersjs

I'm try to update mongodb document in single field, I have doubt to which method i want to use either patch or update using feathers framework, give an example how we can do it. const { authenticate } =…
KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
1
vote
0 answers

I can't send headers with feathersJS rest api /axios. What do I do wrong?

I have feathers API with REST/axios. Configured like this: const axios = require("axios"); const restClient = rest(serverPaths.serverPath.slice(0, -1)); restApi.configure(restClient.axios(axios.create({ headers: {accessToken: '--change---me'}…
SharpBCD
  • 547
  • 1
  • 7
  • 25
1
vote
0 answers

Is there a way to sort by association property? something like /posts?$shallow=false&$sort[user.email]=1

I have 2 models user and post with one-to-many relationship. I'm using feathers js and feathers-sequelize. The response I get when I query post is something like this: [ { "id": 1, "title": "Random title", "userId": 3, "user": { …
desmond
  • 65
  • 1
  • 7
1
vote
0 answers

Feathers.js authentication service uses global entity and service variables when constructing the JWT instead of local entity

I am using feathers.js for my app. In my app, I use different strategies. For all those strategies the entity is user. But I also want to use local strategy for internal operators. The global entity is set to user but for local strategy which I…
1
vote
1 answer

FeathersJs - Sanitize response from Find method in users service broke Authentication service

I created an after hook in the users service that should sanitize the response from the "find" method and it broke the authentication service. The after hook sanitizeResponse should verify if the query is regarding the email or cpf, and, if it is,…
1
vote
0 answers

FeathersJs: Check if user is item creator or creator of associated item

I have two services: posts and comments. Every post can have multiple comments. User 1 creates a post, user 2 creates a comment inside this post. Both users should be able to update, patch or delete the created comment. How do I correctly qualify…
1
vote
4 answers

How to Custom Error Object of Feathersjs?

Let say if I throw GeneralError when call a service, how to make error object like what I want: { "status": "Failed", "code": "500_1", "detail": "Something is wrong with your API" } I already try add this on error hook hook => { hook.error =…
1
vote
1 answer

how to filter the data returned in find FeatherJs

I have this code that returns this result: // Use this hook to manipulate incoming or outgoing data. // For more information on hooks, see: http://docs.feathersjs.com/api/hooks.html module.exports = function (options = {}) { // eslint-disable-line…
1
vote
1 answer

Hook to check if user is authenticate in Feathers (without send Unauthorized error if not, just check)

I want to implement a simple "published" field for the documents in database. For example, if an user is not authenticated, I want to always insert { published: true } in the query for all find/get request, so it will return only published documents…
1
vote
1 answer

How to query a timestamp field by year in Feathersjs?

Currently I have a timestamp field with value format like 1479664146607. What I wanted to do is to get all data with timestamp that has a year of let's say 2017. My current code is non-performant. It gets all the data, and then uses a filter…
wobsoriano
  • 12,348
  • 24
  • 92
  • 162
1
vote
1 answer

Non CRUD Route in FeathersJS

I have a service results that handles all CRUD Operations for the results service in feathersjs. How would I create a route /results/:id/hr_bar_graph which basically fetches the result at that particular id and uses the resulting data to create an…
1
2 3 4