I want to build my own api, I have a custom composer and a custom post type that consists of only an image and title, it acts as a feed.
Inside my theme I want to build a custom api router, for now I have figured out how to add data to the database, but I am limited in the router.
var theme = {};
var db = module.parent.require('./database');
var Categories = module.parent.require("./categories");
theme.init = function(params, callback) {
var app = params.app;
var router = params.router;
app.get('/api/test/:id', function(res, req, next) {
console.log(req.params);
res.json(req)
// db.set('test', req.params.id, function() {
// res.json({working:true});
// });
});
callback(null);
};
The app
in this case is not the typical express app
, it doesn't seem. So I see in the nodebb-custom-pages
plugin bunny parses the url, which is ok I guess, but I am still limited it seems I can only res.render()
I cant use methods like res.json()
.
Any advice?