81 lines
1.8 KiB
JavaScript
Raw Normal View History

2015-10-22 17:54:43 +02:00
'use strict';
/**
* Module dependencies
*/
// Local dependencies.
const explorerActions = require('./explorer/index');
const routesActions = require('./routes/index');
/**
* Public explorer hook
*/
module.exports = function (strapi) {
const hook = {
/**
* Default options
*/
defaults: {
dashboard: {
enabled: true,
token: ''
},
2015-10-22 17:54:43 +02:00
routes: {
'GET /dashboard/explorer/:model/count': {
controller: explorerActions.count,
policies: ['isAuthorized']
},
'POST /dashboard/explorer/:model': {
controller: explorerActions.create,
policies: ['isAuthorized']
},
'DELETE /dashboard/explorer/:model/:id': {
controller: explorerActions.destroy,
policies: ['isAuthorized']
},
'GET /dashboard/explorer/:model': {
controller: explorerActions.find,
policies: ['isAuthorized']
},
'GET /dashboard/explorer/:model/:id': {
controller: explorerActions.findOne,
policies: ['isAuthorized']
},
'PUT /dashboard/explorer/:model': {
controller: explorerActions.update,
policies: ['isAuthorized']
},
'GET /dashboard/routes': {
controller: routesActions.find,
2015-10-27 11:59:38 +01:00
action: 'find',
policies: ['isAuthorized']
2015-10-22 17:54:43 +02:00
},
'PUT /dashboard/routes': {
controller: routesActions.update,
2015-10-27 11:59:38 +01:00
action: 'update',
policies: ['isAuthorized']
2015-10-22 17:54:43 +02:00
}
}
},
/**
* Initialize the hook
*/
initialize: function (cb) {
_.forEach(strapi.hooks.dashboard.defaults.routes, function (route, key) {
strapi.config.routes[key] = route;
});
cb();
}
};
return hook;
};