Skip to content

how to attach middleware like express.static ? #587

@dcsan

Description

@dcsan

Description

I want to send some static files from an app that's also using Bolt.

as per the docs here
I can get the bolt "router" but can't use the normal method to attach express.static middleware.

    const receiver = new ExpressReceiver({ signingSecret: AppConfig.signingSecret });
    app.use(eventLogger) // my own custom middleware

    // but this doesnt work
    // app.use('/cdn', express.static('/cdn'))

currently I have to wire it up with manual send file:

    receiver.router.get('/cdn/*', (req, res) => {
      logger.log('cnd get', req.path)
      const fp = path.join(__dirname, '../../../', req.path)
      res.contentType('image/jpeg');
      res.sendFile(fp);
    })

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionM-T: User needs support to use the project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions