jdx / jdx/mean-sample

Chapter 5 - TypeError: Router.use() requires middleware function but got a Object

Open
#42 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
165
Forks
81
PR merge metrics
No merged PRs in 30d

Description

Hello, I have followed the example through in the book, but for chapter 5 I get the following error
'TypeError: Router.use() requires middleware function but got a Object'

this is associated wit the changes in 'Breaking out the sendfile endpoint'
e.g.
app.use('/', require('./controllers/static'))
I have also tried app.use('/', require('./controllers/static')) - same error
Note: app.use(require('./controllers/api/posts')) works fine

I looked at the downloadable zip file for chapter5 but this is not the same, it uses ejs to provide views, this is not the same as the book. (It has also introduced Morgan too)

At this stage, I would rather not include another dependency (ejs) and just have this work as intended defined in static.js, can you please help ?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.