salix/loopback/server/boot/root.js

42 lines
1007 B
JavaScript
Raw Permalink Normal View History

2017-10-13 14:22:45 +00:00
module.exports = function(app) {
let models = app.models();
models.forEach(function(model) {
let settings = model.settings;
let acls = settings.acls;
if (!acls)
model.settings.acls = acls = [];
acls.unshift({
accessType: '*',
principalType: 'ROLE',
principalId: 'root',
permission: 'ALLOW'
});
acls.push({
accessType: '*',
principalType: 'ROLE',
principalId: '$everyone',
permission: 'DENY'
});
if (settings.validateUpsert === undefined)
settings.validateUpsert = true;
});
app.enableAuth();
// eslint-disable-next-line new-cap
2018-12-27 11:54:16 +00:00
let router = app.loopback.Router();
2017-10-13 14:22:45 +00:00
router.get('/status', app.loopback.status());
app.use(router);
2017-10-13 14:22:45 +00:00
/*
let ds = app.dataSources.auth;
//ds.automigrate(function() {
ds.autoupdate(function() {
console.log('Tables migrated!');
});
*/
};