i used angular-fullstack to scaffold my nodejs application.
Basically i want to use URL's like this:
/api/tvshows/20/seasons/1/eposides/4
.
For every Endpoint the generator creates a new folder in the api dir.
api
->tvshows
->index.js
->tvshows.controller.js
->seasons
->index.js
->seasons.controller.js
and so on
Contents of index.js:
var express = require(express');
var controller = require('./season.controller');
var router = express.Router();
router.get('/', controller.index);
module.exports = router;
my routes.js contains (which is actually not working):
app.use('/api/tvshows/:id/seasons', require('./api/season'));
app.use('/api/tvshows', require('./api/tvshows'));
Is that the right way to organize it? It seems that you cant use :id with app.use().
I do not want to write all the tvshow code in the tvshow controller like this:
router.get('/', controller.index);
router.get('/:id/season', controller.showSeason);
router.get('/:showid/season/:seasonid/episodes', controller.indexSeasonsEpisodes);
router.get('/:showid/season/:seasonid/episodes/:eposideid', controller.showSeasonsEpisode);
Because that is not the modal approach i want to accive. Hope you guys can help me.