ControlledContainerMixin
This mixin allows you to have more control about the way resources and containers are managed. When a container is setup using this mixin, all API calls will redirect to the service. The service can also be called directly by other services.
Warning: If you create a container this way, you should not add it to the
containerssettings of the LDP service.
Usage
const { ControlledContainerMixin } = require('@semapps/ldp');
module.exports = {
name: 'users',
mixins: [ControlledContainerMixin],
settings: {
path: '/users',
acceptedTypes: ['foaf:Person'],
// Other container options
},
actions: {
...
}
}
Settings
All container options are accepted.
Actions
This mixin automatically configures CRUD actions (see below). You can call them directly, or overwrite them.
The
postandlistactions redirect to the LdpContainerService unless they are set. Thelistaction is redirected to the LdpContainerServicegetaction. When called directly, it will automatically guess thecontainerUriparam if it is not set.The
get,create,patch,putanddeleteactions redirect to the LdpResourceService unless they are set.
You can also use Moleculer action hooks if you want to do something before or after each action call.