Configuring backend resources
Javier Escobar edited this page Dec 31, 2017
·
1 revision
Beside NeDB based resources, websemble supports other type of resources, such as file resources or interfaces. The i18n resource is an example of a file resource. An interface is a resource for which one or more methods are implemented. An interface resource must be specified in the backend configuration, like so:
// backend/config.js
module.exports = {
resources: {
Users: [
{
path: "users",
type: "interface"
}
]
}
};
The class to handle such resource should be placed in the backend/resources directory and should be named appending the Resource key word. In our example, the class should be named UsersResource.
// backend/resources/UsersResources.js
class UsersResource {
static get(request) {}
static post(request) {}
static put(request) {}
static delete(request) {}
}