C. Router should be attached with app.use('/admin', adminRouter);
D. Cannot use express.Router() for namespaces
Solution
Step 1: Check app.use syntax
The correct syntax is app.use('/path', router), but here arguments are reversed.
Step 2: Confirm other options
adminRouter.get should be adminRouter.post is incorrect because GET is valid; C is unrelated to namespace error; D is false because express.Router() is used for namespaces.
Final Answer:
Router should be attached with app.use('/admin', adminRouter); -> Option C
Quick Check:
app.use(path, router) order matters [OK]
Hint: app.use(path, router) order is important [OK]
Common Mistakes:
Swapping arguments in app.use
Thinking HTTP method must be POST
Confusing missing listen with routing error
5. You want to create two separate namespaces in Express: '/api' for API routes and '/admin' for admin routes. Which code snippet correctly sets this up?