make index the first param

This commit is contained in:
2016-04-15 16:05:43 -07:00
parent 98f179e64a
commit 600f2eb529
2 changed files with 5 additions and 6 deletions

View File

@@ -3,12 +3,13 @@ import createClient from './helpers/create_client';
import { omit } from 'lodash';
export default class Elastique extends events.EventEmitter {
constructor(options = {}) {
if (!options.index) throw new Error('Must specify an index to write to');
constructor(index, options = {}) {
if (!index) throw new Error('Must specify an index to write to');
super();
this.ready = true;
this.index = index;
this.settings = Object.assign({
interval: '1w',
timeout: 10000,

View File

@@ -9,8 +9,7 @@ describe('Elastique class', function () {
});
it('should throw with an invalid host', function () {
const init = () => new Elastique({
index: 'elastique',
const init = () => new Elastique('elastique', {
client: { host: 'nope://nope' }
});
@@ -18,8 +17,7 @@ describe('Elastique class', function () {
});
it('should throw with invalid hosts', function () {
const init = () => new Elastique({
index: 'elastique',
const init = () => new Elastique('elastique', {
client: { hosts: [{ host: 'localhost', protocol: 'nope' }] }
});