Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"plugins": ["transform-object-assign"],
"plugins": ["transform-object-assign", "add-module-exports"],
"presets": [ "es2015" ]
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ query: {

## Changelog

__1.2.x__

- Babel 6 support, Object.assign polyfill and CommonJS module backwards compatibility

__1.1.0__

- Compatibility with latest service tests
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"compile": "rm -rf lib/ && babel -d lib/ src/",
"jshint": "jshint src/. test/. --config",
"mocha": "mocha test/ --compilers js:babel-core/register",
"test": "npm run jshint && npm run mocha"
"test": "npm run compile && npm run jshint && npm run mocha"
},
"directories": {
"lib": "lib"
Expand All @@ -54,6 +54,7 @@
"devDependencies": {
"babel-cli": "^6.1.4",
"babel-core": "^6.1.4",
"babel-plugin-add-module-exports": "^0.1.1",
"babel-plugin-transform-object-assign": "^6.1.18",
"babel-preset-es2015": "^6.1.4",
"chai": "^3.4.0",
Expand Down
8 changes: 5 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const OPERATORS = {
};

// Create the service.
export const Service = Proto.extend({
const Service = Proto.extend({
init(name, options) {
if(typeof name !== 'string') {
throw new Error('No table name specified.');
Expand Down Expand Up @@ -229,6 +229,8 @@ export const Service = Proto.extend({
}
});

export default module.exports = function() {
export default function create() {
return Proto.create.apply(Service, arguments);
};
}

create.Service = Service;
25 changes: 3 additions & 22 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*jshint expr: true*/

import chai from 'chai';
import assert from 'assert';
import baseTests from 'feathers-service-tests';
import { errors } from 'feathers';
import service from '../src';
Expand All @@ -12,7 +12,6 @@ const options = {
}
};

let expect = chai.expect;
let _ids = {};
let people = service('people', options);

Expand Down Expand Up @@ -57,26 +56,8 @@ describe('Feathers Knex Service', () => {
});
});

describe('init', () => {
describe('without table', () => {
it('throws an error', () => {
expect(service).to.throw('No table name specified.');
});
});

describe.skip('with table', () => {
it('sets up a database connection via config', () => {
// expect(service).to.throw('No table name specified.');
});

it('sets up a database connection via connection string', () => {
// expect(service).to.throw('No table name specified.');
});

it('sets up a database connection via socket config', () => {
// expect(service).to.throw('No table name specified.');
});
});
it('is CommonJS compatible', () => {
assert.equal(typeof require('../lib'), 'function');
});

baseTests(people, _ids, errors.types);
Expand Down