8000 Feature: (req, res, next) handler for *after* the service · Issue #176 · feathersjs/feathers · GitHub
[go: up one dir, main page]

Skip to content

Feature: (req, res, next) handler for *after* the service #176

@dbkaplun

Description

@dbkaplun

Looks like this works:

  app.use(endpoint, function (req, res, next) {
    console.log(`${endpoint} before 1`);
    next();
  }, function (req, res, next) {
    console.log(`${endpoint} before 2`);
    next();
  }, Stream);

But this doesn't: (TypeError: Router.use() requires middleware function but got a Object)

  app.use(endpoint, function (req, res, next) {
    console.log(`${endpoint} before 1`);
    next();
  }, function (req, res, next) {
    console.log(`${endpoint} before 2`);
    next();
  }, Stream, function (req, res, next) {
    console.log(`${endpoint} after`);
    next();
  });

I also tried this, but the after handler simply gets ignored:

  app.use(endpoint, function (req, res, next) {
    console.log(`${endpoint} before 1`);
    next();
  }, function (req, res, next) {
    console.log(`${endpoint} before 2`);
    next();
  }, Stream);
  app.use(endpoint, function (req, res, next) {
    console.log(`${endpoint} after`);
    next();
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0