Warning this is under development. Tests are sparse or incomplete. Use at your own peril.
npm install --save-dev aem-api
Initialize and instance of aem-api
with you credentials, then call any of the listed methods. They
will all return a promise.
const AEM = require('aem-api');
const aem = new AEM('http://localhost', 4502, 'admin', 'admin');
aem.createNode('/tmp/myNode')
.then(_ => {
console.log('Node successfully created')
})
.catch(e => {
console.error('Problem creating node', e);
})
This api returns promises by design even a synchronous response would suffice for ease of use, mainly with generators in mind. With this, it is recommended to use generators where possible for cleaner more readable code.
const AEM = require('aem-api');
const aem = new AEM('http://localhost', 4502, 'admin', 'admin');
const runner = function *() {
const myNode = yield aem.createNode('/tmp/myNode');
yield myNode.activate();
console.warn(`Created my node and activated it, yay, pub o'clock?`);
}
Change almost all response that return a promise to the http response. They're pretty much useless and should remain "behind closed doors". You only want a node object to mess with or an error. Then promise chaining becomes a lot more viable.- Tests
- Economise on http requests where possible (Node#getProperties i'm looking at you...)
Ability to lock and unlock nodes
HTML documentation can be viewed here