Taksh Pratap Singh
Taksh Pratap Singh

Reputation: 183

Is it possible to use multiple middleware functions for just one express endpoint?

Basically, is it possible to write code like this with two middleware functions (authenticateToken and authenticateAdminKey) ?

app.post('/api', authenticateToken, authenticateAdminKey, function() {
 ...
}

I know something similar is possible when you're using multiple middleware for all the endpoints (as mentioned here). But I wanted to know if something like this is possible for just one endpoint?

Upvotes: 1

Views: 707

Answers (1)

kelvin kantaria
kelvin kantaria

Reputation: 1448

middleware list pass in array

app.post('/api', [authenticateToken, authenticateAdminKey], function() {
 ...
}

Upvotes: 4

Related Questions