Cockpit

/api/cockpit/authUser

Authenticate user

fetch('/api/cockpit/authUser?token=xxtokenxx', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        user: 'username',
        password: 'xxpasswordxx'
    })
})
.then(user => res.json())
.then(user => console.log(user));

/api/cockpit/saveUser

Create / Update user

fetch('/api/cockpit/saveUser?token=xxtokenxx', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        user: {...} // user data (user, name, email, active, group)
    })
})
.then(user => res.json())
.then(user => console.log(user));

/api/cockpit/listUsers

Get users.

fetch('/api/cockpit/listUsers?token=xxtokenxx', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        filter: {...}
    })
})
.then(users => users.json())
.then(users => console.log(users));

/api/cockpit/assets

Get assets

fetch('/api/cockpit/assets?token=xxtokenxx', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        filter: {...}
    })
})
.then(assets => assets.json())
.then(assets => console.log(assets));

/api/cockpit/image

Get thumbnail url

fetch('/api/cockpit/image?token=xxtokenxx', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        src: imagePath || asset._id,
        m: ('thumbnail' | 'bestFit' | 'resize' | 'fitToWidth' | 'fitToHeight'),
        w: (int),           // width
        h: (int),           // height
        q: (int),           // quality
        d: (boolean)        // include full domain path
        b64: (boolean)      // return base64 encoded image string
    })
})
.then(url => url.text())
.then(url => console.log(url));
<img src="/api/cockpit/image?token=xxtokenxx&src=path&w=200&h=200&o=true">