Skip to content
Kristijan Horvat edited this page Jan 23, 2017 · 12 revisions

Baasic Module Architecture

To get a better understanding of Baasic AngularJS services below are the details of the main architecture to which all the library services conform to.

SDK Documentation

AngularJS SDK documentation can be found on GitHub and Baasic Developer Center.

Core Services

  • baasicApp service is used to manage Baasic application instances. Multiple AngularJS application instances can be created and coexist at the same time (each will communicate with its corresponding Baasic application).

    For more information please visit the baasicApp documentation.

  • baasicApiHttp

    Baasic HTTP service is used to perform low level communication with the Baasic back-end.

    For more information please visit the baasicApiHttp documentation.

  • baasicApiService

    This service is used to perform low level model or option transformations before they are sent to the Baasic back-end.

    For more information please visit the baasicApiService documentation.

  • baasicConstants

    Baasic constants contain values such as id property name and model property name parameters that can be used in case manual model or option transformation is needed.

HAL links

Resources returned from Baasic are by default in HAL format and they look similar to this:

{
    "key": "<key>",
    "value": "<value>",
    "dateCreated": "2015-01-01T14:24:56.795849Z",
    "dateUpdated": "2015-01-01T14:24:56.795849Z",
    "id": "kZyiWLUzz8dqAjHiO1gxXK",
    "_links": {
        "self": {
            "href": "https://api.baasic.com/<version>/<api-key>/key-values/<key>",
            "templated": false
        },
        "post": {
            "href": "https://api.baasic.com/<version>/<api-key>/key-values",
            "templated": false
        },
        "put": {
            "href": "https://api.baasic.com/<version>/<api-key>/key-values/<key>",
            "templated": false
        },
        "delete": {
            "href": "https://api.baasic.com/<version>/<api-key>/key-values/<key>",
            "templated": false
        }
    },
    "_embedded": { }
}

Note: The preferred way of accessing Bassic back-end is through use of HAL URIs. For manual access to the HAL URIs you can use this (or similar) code:

data.links('put').href
data.links('delete').href

For example, you can also create your own update function by using Baasic core services:

update: function (data) {
    var params = baasicApiService.updateParams(data);
    var url = params[baasicConstants.modelPropertyName].links('put').href;
    var model = params[baasicConstants.modelPropertyName];
    return baasicApiHttp.put(url, model);
},

Extending models

Baasic built-in models can be extended with custom properties by simply setting property values.

article.myProperty = 1;
article.myPropertyObject = {
    firstProp: 1,
    secondProp: 2
}

update: function (article) {
    return articleService.update(article);
}

This powerful feature allows you to extend all built-in models with custom properties which allows modules like Article to fully suit your needs.