Skip to content

Register multiple Express middleware functions #3463

@DowsingUK

Description

@DowsingUK

I could achieve this on FeathersJS v4 using this code:

const { Test } = require('./test.class');

app.use(
    '/test',
    (req, res, next) => {
      res.data = 'Step 1 worked'
      next()
    },
    new Test(options, app), // THIS JUST WORKS 
    (req, res) => {
      res.json({
        message: Hello world from Express middleware ${res.data}
      })
    },
  )

Now I have no idea how to achieve the same on FeathersJS V5

  import { TestService, getOptions } from './test.class'
  import { appUploadsPath, appUploadsMethods } from './app-uploads.shared'

  app.use(
    testPath,
    (req, res, next) => {
      res.data = 'Step 1 worked'
      next()
    },
    new TestService(getOptions(app)), // THIS IS NOT WORKING AT ALL 
    (req, res) => {
      res.json({
        message: Hello world from Express middleware ${res.data}
      })
    },
  )

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions