keystonejs - What is the proper way to set up API endpoints for usage with Keystone? -


it's not clear in docs how 1 use existing keystone models expose api endpoints return json within keystone.js app. able expose rest api endpoints keystone , able use keystone cms capabilities manage content via interacting endpoints. thanks!

now they've standardized admin api found it's pretty trivial use same methods. read apis powering react app i've done put in routes/index.js

router.get('/api/:list/:format(export.csv|export.json)',middleware.initlist,require('keystone/admin/server/api/list/download')); 

and i've made own version of admin initlist middleware:

exports.initlist = function(req, res, next) {   console.log('req.keystone', req.keystone);   req.keystone = keystone;   req.list = keystone.list(req.params.list);   if (!req.list) {     if (req.headers.accept === 'application/json') {       return res.status(404).json({ error: 'invalid list path' });     }     req.flash('error', 'list ' + req.params.list + ' not found.');   }   next(); }; 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -