@feathersjs/express 5.0.0-pre.22 → 5.0.0-pre.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **express:** Ensure Express options can be set before configuring REST transport ([#2655](https://github.com/feathersjs/feathers/issues/2655)) ([c9b8f74](https://github.com/feathersjs/feathers/commit/c9b8f74a0196acb99be44ac5e0fff3f1128288cd))
12
+
13
+
14
+
15
+
16
+
6
17
  # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24)
7
18
 
8
19
  **Note:** Version bump only for package @feathersjs/express
@@ -5,7 +5,7 @@ const commons_1 = require("@feathersjs/commons");
5
5
  const authentication_1 = require("@feathersjs/authentication");
6
6
  const debug = (0, commons_1.createDebug)('@feathersjs/express/authentication');
7
7
  const toHandler = (func) => {
8
- return (req, res, next) => func(req, res, next).catch(error => next(error));
8
+ return (req, res, next) => func(req, res, next).catch((error) => next(error));
9
9
  };
10
10
  function parseAuthentication(settings = {}) {
11
11
  return toHandler(async (req, res, next) => {
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.js","sourceRoot":"","sources":["../src/authentication.ts"],"names":[],"mappings":";;;AAEA,iDAAkD;AAClD,+DAA8E;AAI9E,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,oCAAoC,CAAC,CAAC;AAEhE,MAAM,SAAS,GAAG,CAAC,IAAsE,EAAkB,EAAE;IAC3G,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE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AQ,CAAC,UAAU,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,cAAc,IAAI,EAAE,CAAA;QAEnG,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,KAAK,CAAC,gFAAgF,CAAC,CAAA;YACvF,OAAO,IAAI,EAAE,CAAA;SACd;QAED,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,cAAc,CAAC,CAAA;QAEvE,IAAI,cAAc,EAAE;YAClB,KAAK,CAAC,wCAAwC,EAAE,cAAc,CAAC,CAAA;YAC/D,GAAG,CAAC,QAAQ,GAAG,EAAE,GAAG,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAA;SACnD;QAED,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC;AA1BD,kDA0BC;AAED,SAAgB,YAAY,CAC1B,QAAyC,EACzC,GAAG,UAAoB;IAEvB,MAAM,IAAI,GAAG,IAAA,6BAAgB,EAAC,QAAQ,EAAE,GAAG,UAAU,CAAC,CAAA;IAEtD,OAAO,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACzC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAyB,CAAA;QACzC,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAA;QAC3B,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,MAAM,EAAwB,CAAA;QAErD,MAAM,IAAI,CAAC,OAAO,CAAC,CAAA;QAEnB,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAA;QAE7B,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC;AAjBD,oCAiBC"}
package/lib/handlers.js CHANGED
@@ -45,9 +45,11 @@ function errorHandler(_options = {}) {
45
45
  }
46
46
  if (error.type !== 'FeathersError') {
47
47
  const oldError = error;
48
- error = oldError.errors ? new errors_1.GeneralError(oldError.message, {
49
- errors: oldError.errors
50
- }) : new errors_1.GeneralError(oldError.message);
48
+ error = oldError.errors
49
+ ? new errors_1.GeneralError(oldError.message, {
50
+ errors: oldError.errors
51
+ })
52
+ : new errors_1.GeneralError(oldError.message);
51
53
  if (oldError.stack) {
52
54
  error.stack = oldError.stack;
53
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,+CAA4D;AAG5D,MAAM,QAAQ,GAAG;IACf,MAAM,EAAE,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC;IAC/C,MAAM,EAAE,OAAO;CAChB,CAAC;AACF,MAAM,gBAAgB,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEvE,SAAgB,QAAQ,CAAE,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,EAAE;IAChD,OAAO,UAAU,GAAY,EAAE,IAAc,EAAE,IAAkB;QAC/D,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,iBAAiB,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAE7D,IAAI,CAAC,IAAI,iBAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC;AACJ,CAAC;AAPD,4BAOC;AASD,SAAgB,YAAY,CAAE,WAAgC,EAAE;IAC9D,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEtD,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE;QACvC,OAAO,CAAC,IAAI,GAAG;YACb,GAAG,EAAE,cA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C,OAAO,MAAM,CAAC,KAAK,CAAA;qBACpB;oBAED,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAA;oBAC3C,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBAClB,CAAC,CAAA;aACF;SACF;QAED,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAEtB,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,CAAA;QACrD,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAA;QAExC,iCAAiC;QACjC,IAAI,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;YACxE,SAAS,CAAC,kBAAkB,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;SACrD;aAAM,IAAI,OAAO,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YACjG,SAAS,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;SAC9C;aAAM;YACL,0CAA0C;YAC1C,SAAS,CAAC,kBAAkB,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;SACrD;IACH,CAAC,CAAA;AACH,CAAC;AAzGD,oCAyGC"}
package/lib/index.js CHANGED
@@ -68,7 +68,7 @@ function feathersExpress(feathersApp, expressApp = (0, express_1.default)()) {
68
68
  before: [],
69
69
  after: []
70
70
  });
71
- const hasMethod = (methods) => methods.some(name => (service && typeof service[name] === 'function'));
71
+ const hasMethod = (methods) => methods.some((name) => service && typeof service[name] === 'function');
72
72
  // Check for service (any object with at least one service method)
73
73
  if (hasMethod(['handle', 'set']) || !hasMethod(feathers_1.defaultServiceMethods)) {
74
74
  debug('Passing app.use call to Express app');
@@ -90,7 +90,9 @@ function feathersExpress(feathersApp, expressApp = (0, express_1.default)()) {
90
90
  return server;
91
91
  },
92
92
  async teardown(server) {
93
- return feathersTeardown.call(this, server).then(() => new Promise((resolve, reject) => this.server.close(e => e ? reject(e) : resolve(this))));
93
+ return feathersTeardown
94
+ .call(this, server)
95
+ .then(() => new Promise((resolve, reject) => this.server.close((e) => (e ? reject(e) : resolve(this)))));
94
96
  }
95
97
  });
96
98
  const appDescriptors = {
@@ -103,7 +105,7 @@ function feathersExpress(feathersApp, expressApp = (0, express_1.default)()) {
103
105
  };
104
106
  // Copy all non-existing properties (including non-enumerables)
105
107
  // that don't already exist on the Express app
106
- Object.keys(newDescriptors).forEach(prop => {
108
+ Object.keys(newDescriptors).forEach((prop) => {
107
109
  const appProp = appDescriptors[prop];
108
110
  const newProp = newDescriptors[prop];
109
111
  if (appProp === undefined && newProp !== undefined) {
@@ -111,10 +113,6 @@ function feathersExpress(feathersApp, expressApp = (0, express_1.default)()) {
111
113
  }
112
114
  });
113
115
  app.configure((0, transport_commons_1.routing)());
114
- app.use((req, _res, next) => {
115
- req.feathers = { ...req.feathers, provider: 'rest' };
116
- return next();
117
- });
118
116
  return app;
119
117
  }
120
118
  exports.default = feathersExpress;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,sDAA2C;AAC3C,mDAAiG;AACjG,qEAAwD;AACxD,iDAAkD;AAIlD,mCAAiH;AAAxG,oHAAA,OAAO,OAAY;AAAE,iGAAA,MAAM,OAAA;AAAE,sGAAA,MAAM,OAAe;AAAE,+FAAA,IAAI,OAAA;AAAE,8FAAA,GAAG,OAAA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;IAED,+DAA+D;IAC/D,8CAA8C;IAC9C,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3C,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QACpC,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QAEpC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE;YAClD,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;SACjD;IACH,CAAC,CAAC,CAAA;IAEF,GAAG,CAAC,SAAS,CAAC,IAAA,2BAAO,GAAS,CAAC,CAAA;IAE/B,OAAO,GAAG,CAAA;AACZ,CAAC;AArGD,kCAqGC;AAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IACjC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;CAChE"}
package/lib/rest.js CHANGED
@@ -9,7 +9,7 @@ const feathers_1 = require("@feathersjs/feathers");
9
9
  const authentication_1 = require("./authentication");
10
10
  const debug = (0, commons_1.createDebug)('@feathersjs/express/rest');
11
11
  const toHandler = (func) => {
12
- return (req, res, next) => func(req, res, next).catch(error => next(error));
12
+ return (req, res, next) => func(req, res, next).catch((error) => next(error));
13
13
  };
14
14
  const serviceMiddleware = () => {
15
15
  return toHandler(async (req, res, next) => {
@@ -70,6 +70,10 @@ const rest = (options) => {
70
70
  if (typeof app.route !== 'function') {
71
71
  throw new Error('@feathersjs/express/rest needs an Express compatible app.');
72
72
  }
73
+ app.use((req, _res, next) => {
74
+ req.feathers = { ...req.feathers, provider: 'rest' };
75
+ return next();
76
+ });
73
77
  app.use((0, authentication_1.parseAuthentication)(authenticationOptions));
74
78
  app.use(servicesMiddleware());
75
79
  app.mixins.push((_service, _path, options) => {
package/lib/rest.js.map CHANGED
@@ -1 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QAE7B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC3C,MAAM,EAAE,OAAO,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,CAAA;YAE7D,MAAM,WAAW,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAA;YACtF,MAAM,UAAU,GAAG,IAAA,gBAAM,GAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;YAE5C,OAAO,CAAC,OAAO,KAAf,OAAO,CAAC,OAAO,GAAK,EAAE,EAAA;YACtB,OAAO,CAAC,OAAO,CAAC,QAAQ,GAAG,UAAU,CAAA;QACvC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC,CAAA;AA5BY,QAAA,IAAI,QA4BhB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@feathersjs/express",
3
3
  "description": "Feathers Express framework bindings and REST provider",
4
- "version": "5.0.0-pre.22",
4
+ "version": "5.0.0-pre.23",
5
5
  "homepage": "https://feathersjs.com",
6
6
  "main": "lib/",
7
7
  "types": "lib/",
@@ -51,27 +51,27 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@feathersjs/authentication": "^5.0.0-pre.22",
55
- "@feathersjs/commons": "^5.0.0-pre.22",
56
- "@feathersjs/errors": "^5.0.0-pre.22",
57
- "@feathersjs/feathers": "^5.0.0-pre.22",
58
- "@feathersjs/transport-commons": "^5.0.0-pre.22",
54
+ "@feathersjs/authentication": "^5.0.0-pre.23",
55
+ "@feathersjs/commons": "^5.0.0-pre.23",
56
+ "@feathersjs/errors": "^5.0.0-pre.23",
57
+ "@feathersjs/feathers": "^5.0.0-pre.23",
58
+ "@feathersjs/transport-commons": "^5.0.0-pre.23",
59
59
  "@types/express": "^4.17.13",
60
60
  "@types/express-serve-static-core": "^4.17.28",
61
61
  "express": "^4.18.1"
62
62
  },
63
63
  "devDependencies": {
64
- "@feathersjs/authentication-local": "^5.0.0-pre.22",
65
- "@feathersjs/tests": "^5.0.0-pre.22",
64
+ "@feathersjs/authentication-local": "^5.0.0-pre.23",
65
+ "@feathersjs/tests": "^5.0.0-pre.23",
66
66
  "@types/lodash": "^4.14.182",
67
67
  "@types/mocha": "^9.1.1",
68
- "@types/node": "^17.0.31",
68
+ "@types/node": "^17.0.40",
69
69
  "axios": "^0.27.2",
70
70
  "lodash": "^4.17.21",
71
71
  "mocha": "^10.0.0",
72
72
  "shx": "^0.3.4",
73
- "ts-node": "^10.7.0",
74
- "typescript": "^4.6.4"
73
+ "ts-node": "^10.8.1",
74
+ "typescript": "^4.7.3"
75
75
  },
76
- "gitHead": "e452e02063e6d8943a9cae2315ab585bc4f82fb6"
76
+ "gitHead": "a60910bd730b88053ca6648337095f1ca1e3b39f"
77
77
  }
@@ -1,61 +1,66 @@
1
- import { RequestHandler, Request, Response } from 'express';
2
- import { HookContext } from '@feathersjs/feathers';
3
- import { createDebug } from '@feathersjs/commons';
4
- import { authenticate as AuthenticateHook } from '@feathersjs/authentication';
1
+ import { RequestHandler, Request, Response } from 'express'
2
+ import { HookContext } from '@feathersjs/feathers'
3
+ import { createDebug } from '@feathersjs/commons'
4
+ import { authenticate as AuthenticateHook } from '@feathersjs/authentication'
5
5
 
6
- import { Application } from './declarations';
6
+ import { Application } from './declarations'
7
7
 
8
- const debug = createDebug('@feathersjs/express/authentication');
8
+ const debug = createDebug('@feathersjs/express/authentication')
9
9
 
10
- const toHandler = (func: (req: Request, res: Response, next: () => void) => Promise<void>): RequestHandler => {
11
- return (req, res, next) => func(req, res, next).catch(error => next(error));
12
- };
10
+ const toHandler = (
11
+ func: (req: Request, res: Response, next: () => void) => Promise<void>
12
+ ): RequestHandler => {
13
+ return (req, res, next) => func(req, res, next).catch((error) => next(error))
14
+ }
13
15
 
14
16
  export type AuthenticationSettings = {
15
- service?: string;
16
- strategies?: string[];
17
- };
17
+ service?: string
18
+ strategies?: string[]
19
+ }
18
20
 
19
- export function parseAuthentication (settings: AuthenticationSettings = {}): RequestHandler {
21
+ export function parseAuthentication(settings: AuthenticationSettings = {}): RequestHandler {
20
22
  return toHandler(async (req, res, next) => {
21
- const app = req.app as any as Application;
22
- const service = app.defaultAuthentication?.(settings.service);
23
+ const app = req.app as any as Application
24
+ const service = app.defaultAuthentication?.(settings.service)
23
25
 
24
26
  if (!service) {
25
- return next();
27
+ return next()
26
28
  }
27
29
 
28
- const config = service.configuration;
29
- const authStrategies = settings.strategies || config.parseStrategies || config.authStrategies || [];
30
+ const config = service.configuration
31
+ const authStrategies = settings.strategies || config.parseStrategies || config.authStrategies || []
30
32
 
31
33
  if (authStrategies.length === 0) {
32
- debug('No `authStrategies` or `parseStrategies` found in authentication configuration');
33
- return next();
34
+ debug('No `authStrategies` or `parseStrategies` found in authentication configuration')
35
+ return next()
34
36
  }
35
37
 
36
38
  const authentication = await service.parse(req, res, ...authStrategies)
37
39
 
38
40
  if (authentication) {
39
- debug('Parsed authentication from HTTP header', authentication);
40
- req.feathers = { ...req.feathers, authentication };
41
+ debug('Parsed authentication from HTTP header', authentication)
42
+ req.feathers = { ...req.feathers, authentication }
41
43
  }
42
44
 
43
- return next();
44
- });
45
+ return next()
46
+ })
45
47
  }
46
48
 
47
- export function authenticate (settings: string | AuthenticationSettings, ...strategies: string[]): RequestHandler {
48
- const hook = AuthenticateHook(settings, ...strategies);
49
+ export function authenticate(
50
+ settings: string | AuthenticationSettings,
51
+ ...strategies: string[]
52
+ ): RequestHandler {
53
+ const hook = AuthenticateHook(settings, ...strategies)
49
54
 
50
55
  return toHandler(async (req, _res, next) => {
51
- const app = req.app as any as Application;
52
- const params = req.feathers;
53
- const context = { app, params } as any as HookContext;
56
+ const app = req.app as any as Application
57
+ const params = req.feathers
58
+ const context = { app, params } as any as HookContext
54
59
 
55
- await hook(context);
60
+ await hook(context)
56
61
 
57
- req.feathers = context.params;
62
+ req.feathers = context.params
58
63
 
59
- return next();
60
- });
64
+ return next()
65
+ })
61
66
  }
@@ -1,63 +1,68 @@
1
- import http from 'http';
2
- import express, { Express } from 'express';
1
+ import http from 'http'
2
+ import express, { Express } from 'express'
3
3
  import {
4
- Application as FeathersApplication, Params as FeathersParams,
5
- HookContext, ServiceMethods, ServiceInterface, RouteLookup
6
- } from '@feathersjs/feathers';
4
+ Application as FeathersApplication,
5
+ Params as FeathersParams,
6
+ HookContext,
7
+ ServiceMethods,
8
+ ServiceInterface,
9
+ RouteLookup
10
+ } from '@feathersjs/feathers'
7
11
 
8
12
  interface ExpressUseHandler<T, Services> {
9
- <L extends keyof Services & string> (
13
+ <L extends keyof Services & string>(
10
14
  path: L,
11
15
  ...middlewareOrService: (
12
- Express|express.RequestHandler|express.RequestHandler[]|
13
- (keyof any extends keyof Services ? ServiceInterface : Services[L])
16
+ | Express
17
+ | express.RequestHandler
18
+ | express.RequestHandler[]
19
+ | (keyof any extends keyof Services ? ServiceInterface : Services[L])
14
20
  )[]
15
- ): T;
16
- (path: string|RegExp, ...expressHandlers: express.RequestHandler[]): T;
17
- (...expressHandlers: express.RequestHandler[]): T;
18
- (handler: Express|express.ErrorRequestHandler): T;
21
+ ): T
22
+ (path: string | RegExp, ...expressHandlers: express.RequestHandler[]): T
23
+ (...expressHandlers: express.RequestHandler[]): T
24
+ (handler: Express | express.ErrorRequestHandler): T
19
25
  }
20
26
 
21
27
  export interface ExpressOverrides<Services> {
22
- listen(port: number, hostname: string, backlog: number, callback?: () => void): Promise<http.Server>;
23
- listen(port: number, hostname: string, callback?: () => void): Promise<http.Server>;
24
- listen(port: number|string|any, callback?: () => void): Promise<http.Server>;
25
- listen(callback?: () => void): Promise<http.Server>;
26
- use: ExpressUseHandler<this, Services>;
27
- server: http.Server;
28
+ listen(port: number, hostname: string, backlog: number, callback?: () => void): Promise<http.Server>
29
+ listen(port: number, hostname: string, callback?: () => void): Promise<http.Server>
30
+ listen(port: number | string | any, callback?: () => void): Promise<http.Server>
31
+ listen(callback?: () => void): Promise<http.Server>
32
+ use: ExpressUseHandler<this, Services>
33
+ server: http.Server
28
34
  }
29
35
 
30
- export type Application<Services = any, Settings = any> =
31
- Omit<Express, 'listen'|'use'|'get'|'set'> &
36
+ export type Application<Services = any, Settings = any> = Omit<Express, 'listen' | 'use' | 'get' | 'set'> &
32
37
  FeathersApplication<Services, Settings> &
33
- ExpressOverrides<Services>;
38
+ ExpressOverrides<Services>
34
39
 
35
40
  declare module '@feathersjs/feathers/lib/declarations' {
36
41
  interface ServiceOptions {
37
42
  express?: {
38
- before?: express.RequestHandler[];
39
- after?: express.RequestHandler[];
40
- composed?: express.RequestHandler;
41
- };
43
+ before?: express.RequestHandler[]
44
+ after?: express.RequestHandler[]
45
+ composed?: express.RequestHandler
46
+ }
42
47
  }
43
48
  }
44
49
 
45
50
  declare module 'express-serve-static-core' {
46
51
  interface Request {
47
- feathers?: Partial<FeathersParams> & { [key: string]: any };
48
- lookup?: RouteLookup;
52
+ feathers?: Partial<FeathersParams> & { [key: string]: any }
53
+ lookup?: RouteLookup
49
54
  }
50
55
 
51
56
  interface Response {
52
- data?: any;
53
- hook?: HookContext;
57
+ data?: any
58
+ hook?: HookContext
54
59
  }
55
60
 
56
61
  interface IRouterMatcher<T> {
57
62
  // eslint-disable-next-line
58
63
  <P extends Params = ParamsDictionary, ResBody = any, ReqBody = any>(
59
- path: PathParams,
60
- ...handlers: (RequestHandler<P, ResBody, ReqBody> | Partial<ServiceMethods> | Application)[]
61
- ): T;
64
+ path: PathParams,
65
+ ...handlers: (RequestHandler<P, ResBody, ReqBody> | Partial<ServiceMethods> | Application)[]
66
+ ): T
62
67
  }
63
68
  }
package/src/handlers.ts CHANGED
@@ -1,130 +1,132 @@
1
- import path from 'path';
2
- import { NotFound, GeneralError } from '@feathersjs/errors';
3
- import { Request, Response, NextFunction, ErrorRequestHandler, RequestHandler } from 'express';
1
+ import path from 'path'
2
+ import { NotFound, GeneralError } from '@feathersjs/errors'
3
+ import { Request, Response, NextFunction, ErrorRequestHandler, RequestHandler } from 'express'
4
4
 
5
5
  const defaults = {
6
6
  public: path.resolve(__dirname, '..', 'public'),
7
7
  logger: console
8
- };
9
- const defaultHtmlError = path.resolve(defaults.public, 'default.html');
8
+ }
9
+ const defaultHtmlError = path.resolve(defaults.public, 'default.html')
10
10
 
11
- export function notFound ({ verbose = false } = {}): RequestHandler {
11
+ export function notFound({ verbose = false } = {}): RequestHandler {
12
12
  return function (req: Request, _res: Response, next: NextFunction) {
13
- const url = `${req.url}`;
14
- const message = `Page not found${verbose ? ': ' + url : ''}`;
13
+ const url = `${req.url}`
14
+ const message = `Page not found${verbose ? ': ' + url : ''}`
15
15
 
16
- next(new NotFound(message, { url }));
17
- };
16
+ next(new NotFound(message, { url }))
17
+ }
18
18
  }
19
19
 
20
20
  export type ErrorHandlerOptions = {
21
- public?: string;
22
- logger?: boolean|{ error?: (msg: any) => void, info?: (msg: any) => void };
23
- html?: any;
24
- json?: any;
25
- };
21
+ public?: string
22
+ logger?: boolean | { error?: (msg: any) => void; info?: (msg: any) => void }
23
+ html?: any
24
+ json?: any
25
+ }
26
26
 
27
- export function errorHandler (_options: ErrorHandlerOptions = {}): ErrorRequestHandler {
28
- const options = Object.assign({}, defaults, _options);
27
+ export function errorHandler(_options: ErrorHandlerOptions = {}): ErrorRequestHandler {
28
+ const options = Object.assign({}, defaults, _options)
29
29
 
30
30
  if (typeof options.html === 'undefined') {
31
31
  options.html = {
32
32
  401: path.resolve(options.public, '401.html'),
33
33
  404: path.resolve(options.public, '404.html'),
34
34
  default: defaultHtmlError
35
- };
35
+ }
36
36
  }
37
37
 
38
38
  if (typeof options.json === 'undefined') {
39
- options.json = {};
39
+ options.json = {}
40
40
  }
41
41
 
42
42
  return function (error: any, req: Request, res: Response, next: NextFunction) {
43
43
  // Set the error code for HTTP processing semantics
44
- error.code = !isNaN(parseInt(error.code, 10)) ? parseInt(error.code, 10) : 500;
44
+ error.code = !isNaN(parseInt(error.code, 10)) ? parseInt(error.code, 10) : 500
45
45
 
46
46
  // Log the error if it didn't come from a service method call
47
47
  if (options.logger && typeof options.logger.error === 'function' && !res.hook) {
48
48
  if (error.code >= 500) {
49
- options.logger.error(error);
49
+ options.logger.error(error)
50
50
  } else {
51
- options.logger.info(error);
51
+ options.logger.info(error)
52
52
  }
53
53
  }
54
54
 
55
55
  if (error.type !== 'FeathersError') {
56
- const oldError = error;
56
+ const oldError = error
57
57
 
58
- error = oldError.errors ? new GeneralError(oldError.message, {
59
- errors: oldError.errors
60
- }) : new GeneralError(oldError.message);
58
+ error = oldError.errors
59
+ ? new GeneralError(oldError.message, {
60
+ errors: oldError.errors
61
+ })
62
+ : new GeneralError(oldError.message)
61
63
 
62
64
  if (oldError.stack) {
63
- error.stack = oldError.stack;
65
+ error.stack = oldError.stack
64
66
  }
65
67
  }
66
68
 
67
- const formatter: { [key: string]: any } = {};
69
+ const formatter: { [key: string]: any } = {}
68
70
 
69
71
  // If the developer passed a custom function for ALL html errors
70
72
  if (typeof options.html === 'function') {
71
- formatter['text/html'] = options.html;
73
+ formatter['text/html'] = options.html
72
74
  } else {
73
- let file = options.html[error.code];
75
+ let file = options.html[error.code]
74
76
  if (!file) {
75
- file = options.html.default || defaultHtmlError;
77
+ file = options.html.default || defaultHtmlError
76
78
  }
77
79
  // If the developer passed a custom function for individual html errors
78
80
  if (typeof file === 'function') {
79
- formatter['text/html'] = file;
81
+ formatter['text/html'] = file
80
82
  } else {
81
83
  formatter['text/html'] = function () {
82
- res.set('Content-Type', 'text/html');
83
- res.sendFile(file);
84
- };
84
+ res.set('Content-Type', 'text/html')
85
+ res.sendFile(file)
86
+ }
85
87
  }
86
88
  }
87
89
 
88
90
  // If the developer passed a custom function for ALL json errors
89
91
  if (typeof options.json === 'function') {
90
- formatter['application/json'] = options.json;
92
+ formatter['application/json'] = options.json
91
93
  } else {
92
- const handler = options.json[error.code] || options.json.default;
94
+ const handler = options.json[error.code] || options.json.default
93
95
  // If the developer passed a custom function for individual json errors
94
96
  if (typeof handler === 'function') {
95
- formatter['application/json'] = handler;
97
+ formatter['application/json'] = handler
96
98
  } else {
97
99
  // Don't show stack trace if it is a 404 error
98
100
  if (error.code === 404) {
99
- error.stack = null;
101
+ error.stack = null
100
102
  }
101
103
 
102
104
  formatter['application/json'] = function () {
103
- const output = Object.assign({}, error.toJSON());
105
+ const output = Object.assign({}, error.toJSON())
104
106
 
105
107
  if (process.env.NODE_ENV === 'production') {
106
- delete output.stack;
108
+ delete output.stack
107
109
  }
108
110
 
109
- res.set('Content-Type', 'application/json');
110
- res.json(output);
111
- };
111
+ res.set('Content-Type', 'application/json')
112
+ res.json(output)
113
+ }
112
114
  }
113
115
  }
114
116
 
115
- res.status(error.code);
117
+ res.status(error.code)
116
118
 
117
- const contentType = req.headers['content-type'] || '';
118
- const accepts = req.headers.accept || '';
119
+ const contentType = req.headers['content-type'] || ''
120
+ const accepts = req.headers.accept || ''
119
121
 
120
122
  // by default just send back json
121
123
  if (contentType.indexOf('json') !== -1 || accepts.indexOf('json') !== -1) {
122
- formatter['application/json'](error, req, res, next);
124
+ formatter['application/json'](error, req, res, next)
123
125
  } else if (options.html && (contentType.indexOf('html') !== -1 || accepts.indexOf('html') !== -1)) {
124
- formatter['text/html'](error, req, res, next);
126
+ formatter['text/html'](error, req, res, next)
125
127
  } else {
126
128
  // TODO (EK): Maybe just return plain text
127
- formatter['application/json'](error, req, res, next);
129
+ formatter['application/json'](error, req, res, next)
128
130
  }
129
- };
131
+ }
130
132
  }
package/src/index.ts CHANGED
@@ -1,119 +1,131 @@
1
- import express, { Express } from 'express';
2
- import { Application as FeathersApplication, defaultServiceMethods } from '@feathersjs/feathers';
3
- import { routing } from '@feathersjs/transport-commons';
4
- import { createDebug } from '@feathersjs/commons';
5
-
6
- import { Application } from './declarations';
7
-
8
- export { default as original, static, static as serveStatic, json, raw, text, urlencoded, query } from 'express';
9
-
10
- export * from './authentication';
11
- export * from './declarations';
12
- export * from './handlers';
13
- export * from './rest';
14
-
15
- const debug = createDebug('@feathersjs/express');
16
-
17
- export default function feathersExpress<S = any, C = any> (feathersApp?: FeathersApplication<S, C>, expressApp: Express = express()): Application<S, C> {
1
+ import express, { Express } from 'express'
2
+ import { Application as FeathersApplication, defaultServiceMethods } from '@feathersjs/feathers'
3
+ import { routing } from '@feathersjs/transport-commons'
4
+ import { createDebug } from '@feathersjs/commons'
5
+
6
+ import { Application } from './declarations'
7
+
8
+ export {
9
+ default as original,
10
+ static,
11
+ static as serveStatic,
12
+ json,
13
+ raw,
14
+ text,
15
+ urlencoded,
16
+ query
17
+ } from 'express'
18
+
19
+ export * from './authentication'
20
+ export * from './declarations'
21
+ export * from './handlers'
22
+ export * from './rest'
23
+
24
+ const debug = createDebug('@feathersjs/express')
25
+
26
+ export default function feathersExpress<S = any, C = any>(
27
+ feathersApp?: FeathersApplication<S, C>,
28
+ expressApp: Express = express()
29
+ ): Application<S, C> {
18
30
  if (!feathersApp) {
19
- return expressApp as any;
31
+ return expressApp as any
20
32
  }
21
33
 
22
34
  if (typeof feathersApp.setup !== 'function') {
23
- throw new Error('@feathersjs/express requires a valid Feathers application instance');
35
+ throw new Error('@feathersjs/express requires a valid Feathers application instance')
24
36
  }
25
37
 
26
- const app = expressApp as any as Application<S, C>;
27
- const { use: expressUse, listen: expressListen } = expressApp as any;
28
- const { use: feathersUse, teardown: feathersTeardown } = feathersApp;
38
+ const app = expressApp as any as Application<S, C>
39
+ const { use: expressUse, listen: expressListen } = expressApp as any
40
+ const { use: feathersUse, teardown: feathersTeardown } = feathersApp
29
41
 
30
42
  Object.assign(app, {
31
- use (location: string & keyof S, ...rest: any[]) {
32
- let service: any;
33
- let options = {};
43
+ use(location: string & keyof S, ...rest: any[]) {
44
+ let service: any
45
+ let options = {}
34
46
 
35
- const middleware = rest.reduce(function (middleware, arg) {
47
+ const middleware = rest.reduce(
48
+ function (middleware, arg) {
36
49
  if (typeof arg === 'function' || Array.isArray(arg)) {
37
- middleware[service ? 'after' : 'before'].push(arg);
50
+ middleware[service ? 'after' : 'before'].push(arg)
38
51
  } else if (!service) {
39
- service = arg;
52
+ service = arg
40
53
  } else if (arg.methods || arg.events) {
41
- options = arg;
54
+ options = arg
42
55
  } else {
43
- throw new Error('Invalid options passed to app.use');
56
+ throw new Error('Invalid options passed to app.use')
44
57
  }
45
- return middleware;
46
- }, {
58
+ return middleware
59
+ },
60
+ {
47
61
  before: [],
48
62
  after: []
49
- });
63
+ }
64
+ )
50
65
 
51
- const hasMethod = (methods: string[]) => methods.some(name =>
52
- (service && typeof service[name] === 'function')
53
- );
66
+ const hasMethod = (methods: string[]) =>
67
+ methods.some((name) => service && typeof service[name] === 'function')
54
68
 
55
69
  // Check for service (any object with at least one service method)
56
70
  if (hasMethod(['handle', 'set']) || !hasMethod(defaultServiceMethods)) {
57
- debug('Passing app.use call to Express app');
58
- return expressUse.call(this, location, ...rest);
71
+ debug('Passing app.use call to Express app')
72
+ return expressUse.call(this, location, ...rest)
59
73
  }
60
74
 
61
- debug('Registering service with middleware', middleware);
75
+ debug('Registering service with middleware', middleware)
62
76
  // Since this is a service, call Feathers `.use`
63
77
  feathersUse.call(this, location, service, {
64
78
  ...options,
65
79
  express: middleware
66
- });
80
+ })
67
81
 
68
- return this;
82
+ return this
69
83
  },
70
84
 
71
- async listen (...args: any[]) {
72
- const server = expressListen.call(this, ...args);
85
+ async listen(...args: any[]) {
86
+ const server = expressListen.call(this, ...args)
73
87
 
74
- this.server = server;
75
- await this.setup(server);
76
- debug('Feathers application listening');
88
+ this.server = server
89
+ await this.setup(server)
90
+ debug('Feathers application listening')
77
91
 
78
- return server;
92
+ return server
79
93
  },
80
94
 
81
- async teardown (server?: any) {
82
- return feathersTeardown.call(this, server).then(() =>
83
- new Promise((resolve, reject) => this.server.close(e => e ? reject(e) : resolve(this)))
84
- );
95
+ async teardown(server?: any) {
96
+ return feathersTeardown
97
+ .call(this, server)
98
+ .then(
99
+ () => new Promise((resolve, reject) => this.server.close((e) => (e ? reject(e) : resolve(this))))
100
+ )
85
101
  }
86
- } as Application<S, C>);
102
+ } as Application<S, C>)
87
103
 
88
104
  const appDescriptors = {
89
105
  ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(app)),
90
106
  ...Object.getOwnPropertyDescriptors(app)
91
- };
107
+ }
92
108
  const newDescriptors = {
93
109
  ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(feathersApp)),
94
110
  ...Object.getOwnPropertyDescriptors(feathersApp)
95
- };
111
+ }
96
112
 
97
113
  // Copy all non-existing properties (including non-enumerables)
98
114
  // that don't already exist on the Express app
99
- Object.keys(newDescriptors).forEach(prop => {
100
- const appProp = appDescriptors[prop];
101
- const newProp = newDescriptors[prop];
115
+ Object.keys(newDescriptors).forEach((prop) => {
116
+ const appProp = appDescriptors[prop]
117
+ const newProp = newDescriptors[prop]
102
118
 
103
119
  if (appProp === undefined && newProp !== undefined) {
104
- Object.defineProperty(expressApp, prop, newProp);
120
+ Object.defineProperty(expressApp, prop, newProp)
105
121
  }
106
- });
122
+ })
107
123
 
108
- app.configure(routing() as any);
109
- app.use((req, _res, next) => {
110
- req.feathers = { ...req.feathers, provider: 'rest' };
111
- return next();
112
- });
124
+ app.configure(routing() as any)
113
125
 
114
- return app;
126
+ return app
115
127
  }
116
128
 
117
129
  if (typeof module !== 'undefined') {
118
- module.exports = Object.assign(feathersExpress, module.exports);
130
+ module.exports = Object.assign(feathersExpress, module.exports)
119
131
  }
package/src/rest.ts CHANGED
@@ -1,110 +1,116 @@
1
- import { Request, Response, RequestHandler, Router } from 'express';
2
- import { MethodNotAllowed } from '@feathersjs/errors';
3
- import { createDebug } from '@feathersjs/commons';
4
- import { http } from '@feathersjs/transport-commons';
5
- import { createContext, defaultServiceMethods, getServiceOptions } from '@feathersjs/feathers';
1
+ import { Request, Response, RequestHandler, Router } from 'express'
2
+ import { MethodNotAllowed } from '@feathersjs/errors'
3
+ import { createDebug } from '@feathersjs/commons'
4
+ import { http } from '@feathersjs/transport-commons'
5
+ import { createContext, defaultServiceMethods, getServiceOptions } from '@feathersjs/feathers'
6
6
 
7
- import { AuthenticationSettings, parseAuthentication } from './authentication';
8
- import { Application } from './declarations';
7
+ import { AuthenticationSettings, parseAuthentication } from './authentication'
8
+ import { Application } from './declarations'
9
9
 
10
- const debug = createDebug('@feathersjs/express/rest');
10
+ const debug = createDebug('@feathersjs/express/rest')
11
11
 
12
- const toHandler = (func: (req: Request, res: Response, next: () => void) => Promise<void>): RequestHandler => {
13
- return (req, res, next) => func(req, res, next).catch(error => next(error));
14
- };
12
+ const toHandler = (
13
+ func: (req: Request, res: Response, next: () => void) => Promise<void>
14
+ ): RequestHandler => {
15
+ return (req, res, next) => func(req, res, next).catch((error) => next(error))
16
+ }
15
17
 
16
18
  const serviceMiddleware = (): RequestHandler => {
17
19
  return toHandler(async (req, res, next) => {
18
- const { query, headers, path, body: data, method: httpMethod } = req;
19
- const methodOverride = req.headers[http.METHOD_HEADER] as string | undefined;
20
+ const { query, headers, path, body: data, method: httpMethod } = req
21
+ const methodOverride = req.headers[http.METHOD_HEADER] as string | undefined
20
22
 
21
- const { service, params: { __id: id = null, ...route } = {} } = req.lookup!;
22
- const method = http.getServiceMethod(httpMethod, id, methodOverride);
23
- const { methods } = getServiceOptions(service);
23
+ const { service, params: { __id: id = null, ...route } = {} } = req.lookup!
24
+ const method = http.getServiceMethod(httpMethod, id, methodOverride)
25
+ const { methods } = getServiceOptions(service)
24
26
 
25
- debug(`Found service for path ${path}, attempting to run '${method}' service method`);
27
+ debug(`Found service for path ${path}, attempting to run '${method}' service method`)
26
28
 
27
29
  if (!methods.includes(method) || defaultServiceMethods.includes(methodOverride)) {
28
- const error = new MethodNotAllowed(`Method \`${method}\` is not supported by this endpoint.`);
29
- res.statusCode = error.code;
30
- throw error;
30
+ const error = new MethodNotAllowed(`Method \`${method}\` is not supported by this endpoint.`)
31
+ res.statusCode = error.code
32
+ throw error
31
33
  }
32
34
 
33
- const createArguments = http.argumentsFor[method as 'get'] || http.argumentsFor.default;
34
- const params = { query, headers, route, ...req.feathers };
35
- const args = createArguments({ id, data, params });
36
- const contextBase = createContext(service, method, { http: {} });
37
- res.hook = contextBase;
35
+ const createArguments = http.argumentsFor[method as 'get'] || http.argumentsFor.default
36
+ const params = { query, headers, route, ...req.feathers }
37
+ const args = createArguments({ id, data, params })
38
+ const contextBase = createContext(service, method, { http: {} })
39
+ res.hook = contextBase
38
40
 
39
- const context = await (service as any)[method](...args, contextBase);
40
- res.hook = context;
41
+ const context = await (service as any)[method](...args, contextBase)
42
+ res.hook = context
41
43
 
42
- const response = http.getResponse(context);
43
- res.statusCode = response.status;
44
- res.set(response.headers);
45
- res.data = response.body;
44
+ const response = http.getResponse(context)
45
+ res.statusCode = response.status
46
+ res.set(response.headers)
47
+ res.data = response.body
46
48
 
47
- return next();
48
- });
49
- };
49
+ return next()
50
+ })
51
+ }
50
52
 
51
53
  const servicesMiddleware = (): RequestHandler => {
52
54
  return toHandler(async (req, res, next) => {
53
- const app = req.app as any as Application;
54
- const lookup = app.lookup(req.path);
55
+ const app = req.app as any as Application
56
+ const lookup = app.lookup(req.path)
55
57
 
56
58
  if (!lookup) {
57
- return next();
59
+ return next()
58
60
  }
59
61
 
60
- req.lookup = lookup;
62
+ req.lookup = lookup
61
63
 
62
- const options = getServiceOptions(lookup.service);
63
- const middleware = options.express!.composed!;
64
+ const options = getServiceOptions(lookup.service)
65
+ const middleware = options.express.composed
64
66
 
65
- return middleware(req, res, next);
66
- });
67
- };
67
+ return middleware(req, res, next)
68
+ })
69
+ }
68
70
 
69
71
  export const formatter: RequestHandler = (_req, res, next) => {
70
72
  if (res.data === undefined) {
71
- return next();
73
+ return next()
72
74
  }
73
75
 
74
76
  res.format({
75
- 'application/json' () {
76
- res.json(res.data);
77
+ 'application/json'() {
78
+ res.json(res.data)
77
79
  }
78
- });
79
- };
80
+ })
81
+ }
80
82
 
81
83
  export type RestOptions = {
82
- formatter?: RequestHandler;
83
- authentication?: AuthenticationSettings;
84
- };
84
+ formatter?: RequestHandler
85
+ authentication?: AuthenticationSettings
86
+ }
85
87
 
86
88
  export const rest = (options?: RestOptions | RequestHandler) => {
87
- options = typeof options === 'function' ? { formatter: options } : options || {};
89
+ options = typeof options === 'function' ? { formatter: options } : options || {}
88
90
 
89
- const formatterMiddleware = options.formatter || formatter;
90
- const authenticationOptions = options.authentication;
91
+ const formatterMiddleware = options.formatter || formatter
92
+ const authenticationOptions = options.authentication
91
93
 
92
94
  return (app: Application) => {
93
95
  if (typeof app.route !== 'function') {
94
- throw new Error('@feathersjs/express/rest needs an Express compatible app.');
96
+ throw new Error('@feathersjs/express/rest needs an Express compatible app.')
95
97
  }
96
98
 
97
- app.use(parseAuthentication(authenticationOptions));
98
- app.use(servicesMiddleware());
99
+ app.use((req, _res, next) => {
100
+ req.feathers = { ...req.feathers, provider: 'rest' }
101
+ return next()
102
+ })
103
+ app.use(parseAuthentication(authenticationOptions))
104
+ app.use(servicesMiddleware())
99
105
 
100
106
  app.mixins.push((_service, _path, options) => {
101
- const { express: { before = [], after = [] } = {} } = options;
107
+ const { express: { before = [], after = [] } = {} } = options
102
108
 
103
- const middlewares = [].concat(before, serviceMiddleware(), after, formatterMiddleware);
104
- const middleware = Router().use(middlewares);
109
+ const middlewares = [].concat(before, serviceMiddleware(), after, formatterMiddleware)
110
+ const middleware = Router().use(middlewares)
105
111
 
106
- options.express ||= {};
107
- options.express.composed = middleware;
108
- });
109
- };
112
+ options.express ||= {}
113
+ options.express.composed = middleware
114
+ })
115
+ }
110
116
  }