The API routes file contains a mapping of names to API endpoints. This is a guide to using that file and the associated modules.
Defining API routes
The src/media/js/routes_api.js
file is a module that returns an object containing API endpoint name to API URL endpoint mappings. For example:
define('routes_api', [], function() {
return {
'route': '/foo/bar/{0}',
'another_route': '/foo/bar/{0}/asdf'
};
});
The above routes would be used like this:
require('url').api.url('route', ['path']);
// "foo/bar/path"
This module should NOT have any dependencies, as this file may be required by any number of other modules and any dependencies risk a dependency loop.
API routes will be generated using the format
module, though named parameters are not encouraged.