After migrating to v5 from v4 the matching service name collides with the rest defined endpoints.
Description
It is not really an issue, but something I have faced while upgrading from version 4 to version 5.
In version 4 I have a service named items, with some custom events:
const createService = require("feathers-memory");
module.exports = function (app) {
class Items {
constructor() {
this.items = [];
}
}
// Initialize our service with any options it requires
app.use(
"/items",
createService({
events: [
...custom_events
],
Items,
}),
);
};I also had the rest endpoint defined:
app.post("/items/new", (req, res) => {
const { body } = req;
const itemsService = app.service("items");
itemsService.emit("new_item", body);
res.status(200);
res.json({
data: "Success",
});
});So when calling the app with items/new endpoint it will go to the defined rest endpoint handler and emit the event.
After upgrading to v5, the services file was updated to:
import { Application, Params } from "@feathersjs/feathers";
export default function (app: Application) {
class ItemsService {
async create(_data: any, _params: Params) {
return [];
}
}
// Initialize our service with any options it requires
app.use("/items", new ItemsService(), {
events: [
...custom_events
],
});
}and the rest endpoint definition is the same as before, but the issue now is when calling a post request with items/new
the service create is being called not the rest defined endpoint.
Is there a way to explicitly set the priority for the rest defined endpoint?
Just renaming a service is an option but in this case, the relevant clients have to update the service names as well.
Source: feathersjs/feathers