Skip to content

Commit 2dafb7c

Browse files
authored
feat: Feathers v5 core refactoring and features (#2255)
BREAKING CHANGES: `app.setup` and `app.listen` are asynchronous. Several TypeScript usability improvements that are not backwards compatible. Removal of several internal APIs that were not publicly documented.
1 parent bbe7e2a commit 2dafb7c

File tree

86 files changed

+2868
-3704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2868
-3704
lines changed

.codeclimate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ checks:
1111
threshold: 300
1212
method-complexity:
1313
config:
14-
threshold: 6
14+
threshold: 8
1515
method-count:
1616
config:
1717
threshold: 20

.mocharc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"timeout": 20000,
33
"require": [ "ts-node/register", "source-map-support/register" ],
44
"reporter": "Dot",
5+
"extension": ".test.ts",
56
"exit": true
67
}

packages/adapter-commons/src/service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ export class AdapterService<T = any> implements ServiceMethods<T|Paginated<T>> {
173173

174174
create (data: Partial<T>, params?: Params): Promise<T>;
175175
create (data: Partial<T>[], params?: Params): Promise<T[]>;
176-
create (data: Partial<T> | Partial<T>[], params?: Params): Promise<T | T[]>;
177176
create (data: Partial<T> | Partial<T>[], params?: Params): Promise<T | T[]> {
178177
if (Array.isArray(data) && !this.allowsMulti('create')) {
179178
return Promise.reject(new MethodNotAllowed('Can not create multiple entries'));
@@ -213,4 +212,6 @@ export class AdapterService<T = any> implements ServiceMethods<T|Paginated<T>> {
213212

214213
return callMethod(this, '_remove', id, params);
215214
}
215+
216+
async setup () {}
216217
}

packages/adapter-memory/test/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'assert';
22
import adapterTests from '@feathersjs/adapter-tests';
33
import errors from '@feathersjs/errors';
4-
import feathers from '@feathersjs/feathers';
4+
import { feathers } from '@feathersjs/feathers';
55

66
import { memory } from '../src';
77

@@ -85,7 +85,7 @@ describe('Feathers Memory Service', () => {
8585
age: 33
8686
});
8787

88-
const updatedPerson = await people.update(person.id.toString(), person);
88+
const updatedPerson: any = await people.update(person.id.toString(), person);
8989

9090
assert.strictEqual(typeof updatedPerson.id, 'number');
9191

packages/authentication-client/src/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class AuthenticationClient {
4343
options: AuthenticationClientOptions;
4444

4545
constructor (app: Application, options: AuthenticationClientOptions) {
46-
const socket = app.io || (app as any).primus;
46+
const socket = app.io;
4747
const storage = new StorageWrapper(app.get('storage') || options.storage);
4848

4949
this.app = app;

packages/authentication-client/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import assert from 'assert';
2-
import feathers, { Application } from '@feathersjs/feathers';
2+
import { feathers, Application } from '@feathersjs/feathers';
33

44
import client from '../src';
55
import { AuthenticationClient } from '../src';

packages/authentication-client/test/integration/express.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from 'axios';
2-
import feathers, { Application as FeathersApplication } from '@feathersjs/feathers';
2+
import { Server } from 'http';
3+
import { feathers, Application as FeathersApplication } from '@feathersjs/feathers';
34
import * as express from '@feathersjs/express';
45
import rest from '@feathersjs/rest-client';
56

@@ -9,17 +10,17 @@ import commonTests from './commons';
910

1011
describe('@feathersjs/authentication-client Express integration', () => {
1112
let app: express.Application;
12-
let server: any;
13+
let server: Server;
1314

14-
before(() => {
15+
before(async () => {
1516
const restApp = express.default(feathers())
1617
.use(express.json())
1718
.configure(express.rest())
1819
.use(express.parseAuthentication());
1920
app = getApp(restApp as unknown as FeathersApplication) as express.Application;
2021
app.use(express.errorHandler());
2122

22-
server = app.listen(9776);
23+
server = await app.listen(9776);
2324
});
2425

2526
after(done => server.close(() => done()));

packages/authentication-client/test/integration/socketio.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { io } from 'socket.io-client';
22
import assert from 'assert';
3-
import feathers, { Application } from '@feathersjs/feathers';
3+
import { feathers, Application } from '@feathersjs/feathers';
44
import socketio from '@feathersjs/socketio';
55
import socketioClient from '@feathersjs/socketio-client';
66

@@ -11,10 +11,10 @@ import commonTests from './commons';
1111
describe('@feathersjs/authentication-client Socket.io integration', () => {
1212
let app: Application;
1313

14-
before(() => {
14+
before(async () => {
1515
app = getApp(feathers().configure(socketio()));
1616

17-
app.listen(9777);
17+
await app.listen(9777);
1818
});
1919

2020
after(done => app.io.close(() => done()));

packages/authentication-local/src/hooks/hash-password.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function hashPassword (field: string, options: HashPasswordOption
1818
throw new Error('The hashPassword hook requires a field name option');
1919
}
2020

21-
return async (context: HookContext) => {
21+
return async (context: HookContext<any, any>) => {
2222
if (context.type !== 'before') {
2323
throw new Error('The \'hashPassword\' hook should only be used as a \'before\' hook');
2424
}

packages/authentication-local/src/hooks/protect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import omit from 'lodash/omit';
22
import { HookContext } from '@feathersjs/feathers';
33

4-
export default (...fields: string[]) => (context: HookContext) => {
4+
export default (...fields: string[]) => (context: HookContext<any, any>) => {
55
const result = context.dispatch || context.result;
66
const o = (current: any) => {
77
if (typeof current === 'object' && !Array.isArray(current)) {

0 commit comments

Comments
 (0)