| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Great ! The only thing that bothers me is that the arguments are not free. The signature of a method must be [data, params] and I currently have custom methods that expect [id, params] or [id, data, params]. Maybe we can add flexibly if we give an array of argument to body? Which could be empty and to which we would concatenate params from the url. |
Sorry, something went wrong.
|
Oh, I forgot to mention, that I added a middleware that should still allow to register any other kinds of custom methods: const { createContext } = require('@feathersjs/feathers');
const { serviceMiddleware } = require('@feathersjs/express');
app.use('/myservice', myservice);
// With custom method handler
app.get('/myservice/:__feathersId/my-method', serviceMiddleware(async ({ req, res, options }) => {
// options.id - __feathersId
// options.params - Service params
// options.data - body
const { params, id } = options;
return app.service('my-service').myCustomMethod(id, params);
}));
// With different params, using the body and returning the context (when using it with hooks)
app.post('/myservice/:myId/myMethod', serviceMiddleware(async ({ req, res, options }) => {
const { myId } = req.params;
const { params, data } = options;
const context = createContext(service, method);
return app.service('my-service').myCustomMethod(myId, data, params, context);
}));It's not as declarative but I'm hoping it to be more flexible and explicit. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This pull request implements tests and client side functionality for custom service methods outlined in and closes #1976.
On the server a custom service method is added like this:
It can be used via an HTTP and socket API directly as described in #1976.
On the Feathers client it is used like this:
TypeScript has a CustomMethod and client interface: