@meilisearch/meili-api
Version:
The MeiliSearch JS client for Node.js and the browser.
144 lines • 3.82 kB
JavaScript
/*
* Bundle: Meili
* Project: Meili - Javascript API
* Author: Quentin de Quelen <quentin@meilisearch.com>
* Copyright: 2019, Meili
*/
'use strict';
import instance from 'axios';
import { Indexes } from './indexes';
var Meili = /** @class */ (function () {
function Meili(config) {
this.baseURL = config.host;
this.apiKey = config.apiKey;
if (config.apiKey) {
this.instance = instance.create({
baseURL: this.baseURL,
timeout: 1000,
headers: {
'X-Meili-API-Key': config.apiKey,
},
});
}
else {
this.instance = instance.create({
baseURL: this.baseURL,
timeout: 1000,
});
}
this.instance.interceptors.response.use(function (response) { return response.data; });
}
/**
* Return an Index instance
* @memberof Meili
* @method Index
*/
Meili.prototype.Index = function (indexUid) {
return new Indexes(this.instance, indexUid);
};
/**
* List all indexes in the database
* @memberof Meili
* @method listIndexes
*/
Meili.prototype.listIndexes = function () {
var url = '/indexes';
return this.instance.get(url);
};
/**
* Create a new index with am optional schema
* @memberof Meili
* @method createIndex
*/
Meili.prototype.createIndex = function (data) {
var url = "/indexes";
return this.instance.post(url, data);
};
///
/// HEALTH
///
/**
* Check if the server is healhty
* @memberof Admin
* @method isHealthy
*/
Meili.prototype.isHealthy = function () {
var url = '/health';
return this.instance.get(url).then(function (res) { return true; });
};
/**
* Change the healthyness to healthy
* @memberof Admin
* @method setHealthy
*/
Meili.prototype.setHealthy = function () {
var url = '/health';
return this.instance.put(url, {
health: true,
});
};
/**
* Change the healthyness to unhealthy
* @memberof Admin
* @method setUnhealthy
*/
Meili.prototype.setUnhealthy = function () {
var url = '/health';
return this.instance.put(url, {
health: false,
});
};
/**
* Change the healthyness to unhealthy
* @memberof Admin
* @method setUnhealthy
*/
Meili.prototype.changeHealthTo = function (health) {
var url = '/health';
return this.instance.put(url, {
health: health,
});
};
///
/// STATS
///
/**
* Get the stats of all the database
* @memberof Admin
* @method databaseStats
*/
Meili.prototype.databaseStats = function () {
var url = '/stats';
return this.instance.get(url);
};
/**
* Get the version of the server
* @memberof Admin
* @method version
*/
Meili.prototype.version = function () {
var url = '/version';
return this.instance.get(url);
};
/**
* Get the server consuption, RAM / CPU / Network
* @memberof Admin
* @method systemInformation
*/
Meili.prototype.systemInformation = function () {
var url = '/sys-info';
return this.instance.get(url);
};
/**
* Get the server consuption, RAM / CPU / Network. All information as human readable
* @memberof Admin
* @method systemInformationPretty
*/
Meili.prototype.systemInformationPretty = function () {
var url = '/sys-info/pretty';
return this.instance.get(url);
};
return Meili;
}());
export default Meili;
//# sourceMappingURL=index.js.map