fluro
Version:
Promise based HTTP Fluro client for the browser and node.js
259 lines (198 loc) • 10.6 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>api/fluro.core.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FluroAccess.html">FluroAccess</a><ul class='methods'><li data-type='method'><a href="FluroAccess.html#.retrieveCurrentSession">retrieveCurrentSession</a></li><li data-type='method'><a href="FluroAccess.html#.setDefaultApplication">setDefaultApplication</a></li></ul></li><li><a href="FluroAPI.html">FluroAPI</a></li><li><a href="FluroAsset.html">FluroAsset</a><ul class='methods'><li data-type='method'><a href="FluroAsset.html#.avatarUrl">avatarUrl</a></li><li data-type='method'><a href="FluroAsset.html#.downloadUrl">downloadUrl</a></li><li data-type='method'><a href="FluroAsset.html#.filesize">filesize</a></li><li data-type='method'><a href="FluroAsset.html#.getUrl">getUrl</a></li><li data-type='method'><a href="FluroAsset.html#.imageUrl">imageUrl</a></li><li data-type='method'><a href="FluroAsset.html#.posterUrl">posterUrl</a></li></ul></li><li><a href="FluroAuth.html">FluroAuth</a><ul class='methods'><li data-type='method'><a href="FluroAuth.html#.addEventListener">addEventListener</a></li><li data-type='method'><a href="FluroAuth.html#.changeAccount">changeAccount</a></li><li data-type='method'><a href="FluroAuth.html#.getCurrentToken">getCurrentToken</a></li><li data-type='method'><a href="FluroAuth.html#.getCurrentUser">getCurrentUser</a></li><li data-type='method'><a href="FluroAuth.html#.login">login</a></li><li data-type='method'><a href="FluroAuth.html#.logout">logout</a></li><li data-type='method'><a href="FluroAuth.html#.refreshAccessToken">refreshAccessToken</a></li><li data-type='method'><a href="FluroAuth.html#.removeAllListeners">removeAllListeners</a></li><li data-type='method'><a href="FluroAuth.html#.removeEventListener">removeEventListener</a></li><li data-type='method'><a href="FluroAuth.html#.sendResetPasswordRequest">sendResetPasswordRequest</a></li><li data-type='method'><a href="FluroAuth.html#.set">set</a></li><li data-type='method'><a href="FluroAuth.html#.signup">signup</a></li></ul></li><li><a href="FluroCache.html">FluroCache</a><ul class='methods'><li data-type='method'><a href="FluroCache.html#.get">get</a></li><li data-type='method'><a href="FluroCache.html#.reset">reset</a></li></ul></li><li><a href="FluroContent.html">FluroContent</a><ul class='methods'><li data-type='method'><a href="FluroContent.html#.external">external</a></li><li data-type='method'><a href="FluroContent.html#.get">get</a></li><li data-type='method'><a href="FluroContent.html#.query">query</a></li><li data-type='method'><a href="FluroContent.html#.retrieve">retrieve</a></li><li data-type='method'><a href="FluroContent.html#.search">search</a></li><li data-type='method'><a href="FluroContent.html#.slug">slug</a></li></ul></li><li><a href="FluroCore.html">FluroCore</a></li><li><a href="FluroDate.html">FluroDate</a><ul class='methods'><li data-type='method'><a href="FluroDate.html#.localDate">localDate</a></li><li data-type='method'><a href="FluroDate.html#.readableEventDate">readableEventDate</a></li></ul></li><li><a href="FluroTypes.html">FluroTypes</a><ul class='methods'><li data-type='method'><a href="FluroTypes.html#.retrieve">retrieve</a></li></ul></li><li><a href="FluroUtils.html">FluroUtils</a><ul class='methods'><li data-type='method'><a href="FluroUtils.html#.arrayIDs">arrayIDs</a></li><li data-type='method'><a href="FluroUtils.html#.comma">comma</a></li><li data-type='method'><a href="FluroUtils.html#.errorMessage">errorMessage</a></li><li data-type='method'><a href="FluroUtils.html#.getStringID">getStringID</a></li><li data-type='method'><a href="FluroUtils.html#.mapParameters">mapParameters</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-fluro.html">fluro</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">api/fluro.core.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>import FluroAPI from './fluro.api';
import FluroAuth from './fluro.auth';
import FluroAsset from './fluro.asset';
import FluroUtils from './fluro.utils';
import FluroCache from './fluro.cache';
import FluroDate from './fluro.date';
import FluroStats from './fluro.stats';
import FluroTypes from './fluro.types';
import FluroContent from './fluro.content';
import FluroAccess from './fluro.access';
///////////////////////////////////////
/**
* Creates a new FluroCore instance including all of the default sub modules
*
* @constructor
*
* @param {Object} options
* @param {String} options.apiURL The remote URL of the Fluro API you want to connect to. Options are 'staging', 'production' or you may set a specific URL eg. 'https://api.fluro.io' (do not include trailing slash). If no value is provided, will default to 'production'.
* @param {String} options.applicationToken When running as a static application, (for example a website) you may set the application's access token before you initialize the Fluro instance here.
*/
var FluroCore = function(options) {
if (!options) {
options = {
// apiURL,
// applicationToken,
// api:{}
};
}
///////////////////////////////////////
if (!options.apiURL || !options.apiURL.length) {
options.apiURL = 'production';
}
///////////////////////////////////////
switch (options.apiURL) {
case 'production':
options.apiURL = 'https://api.fluro.io';
break;
case 'staging':
options.apiURL = 'https://api.staging.fluro.io';
break;
case 'local':
options.apiURL = 'http://api.fluro.localhost:3000';
break;
}
///////////////////////////////////////
var core = {
apiURL: options.apiURL,
applicationToken: options.applicationToken,
domain:options.domain || '',
}
///////////////////////////////////////
/**
* Provides a cache service, used for creating, clearing
* and storing API requests and other information in memory
* @type {FluroCache}
*/
var cache = FluroCache;
Object.defineProperty(core, 'cache', {
value: cache,
writable: false,
});
///////////////////////////////////////
/**
* Provides helper functions for working
* with Fluro data
* @type {FluroUtils}
*/
var utils = FluroUtils;
Object.defineProperty(core, 'utils', {
value: utils,
writable: false,
});
/**
* Provides date functions, filters and utilities
* for working with dates and timezones
* @type {FluroDate}
*/
var date = FluroDate;
Object.defineProperty(core, 'date', {
value: date,
writable: false,
});
/**
* The default service for interacting with
* the Fluro REST API, it's a wrapper around the axios library
* that works in conjunction with the other Fluro modules
* @type {FluroAPI}
*/
var api = new FluroAPI(core);
Object.defineProperty(core, 'api', {
value: api,
writable: false,
});
/**
* A helper service for CRUD operations that wraps around the fluro.api service
* @type {FluroContent}
*/
var content = new FluroContent(core);
Object.defineProperty(core, 'content', {
value: content,
writable: false,
});
/**
* The default service for managing authentication
* handles automatic refreshing of access tokens, and provides login, logout
* and other user/application specific functionality
* @type {FluroAuth}
*/
var auth = new FluroAuth(core);
Object.defineProperty(core, 'auth', {
value: auth,
writable: false,
});
/**
* A helper service for understanding a user's access permissions
* @type {FluroAccess}
*/
var access = new FluroAccess(core);
Object.defineProperty(core, 'access', {
value: access,
writable: false,
});
/**
* The default service for managing, rendering and handling files and media from Fluro.
* It contains helper functions for managing connecting to image, audio, asset and video api endpoints.
* @type {FluroAsset}
*/
var asset = new FluroAsset(core);
Object.defineProperty(core, 'asset', {
value: asset,
writable: false,
});
/**
* The default service for handling a user's 'stats' eg. (likes, views, favorites, downvotes etc...)
* This service creates and syncs user's stats when they 'stat' items from Fluro.
* @type {FluroStats}
*/
var stats = new FluroStats(core)
Object.defineProperty(core, 'stats', {
value: new FluroStats(core),
writable: false,
});
/**
* A helper service for retrieving, translating and rendering content types and definitions
* defined within Fluro.
* @type {FluroTypes}
*/
var types = new FluroTypes(core);
Object.defineProperty(core, 'types', {
value: types,
writable: false,
});
///////////////////////////////////////
return core;
}
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
export default FluroCore;</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Apr 24 2019 19:46:45 GMT+1000 (Australian Eastern Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>