DEV Community

Discussion on: How do you implement REST in an MVC application?

Collapse
 
princebillygk profile image
Prince Billy Graham Karmoker • Edited

I will create a separate API folder in my root directory which will contains its own routes/ and controllers/ folder but the models/, services/ and lib/ folder will be in the root directory shared by both website and API. And then
Import apiRouter from './api/routes/index'
Import genralRouter from 'routes/index'
app.use('/api/', apiRouter)
app.use('/', generalRouter)