@feathersjs/express 5.0.0-pre.2 → 5.0.0-pre.20

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,193 @@
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.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507))
12
+
13
+
14
+
15
+
16
+
17
+ # [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **express:** Fix typo in types reference in package.json ([#2613](https://github.com/feathersjs/feathers/issues/2613)) ([eacf1b3](https://github.com/feathersjs/feathers/commit/eacf1b3474e6d9da69b8671244c23a75cff87d95))
23
+
24
+
25
+ ### Features
26
+
27
+ * **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28))
28
+
29
+
30
+
31
+
32
+
33
+ # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
34
+
35
+
36
+ ### Features
37
+
38
+ * **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023))
39
+ * **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa))
40
+ * **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5))
41
+
42
+
43
+
44
+
45
+
46
+ # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * **express:** Fix application typings to work with typed configuration ([#2539](https://github.com/feathersjs/feathers/issues/2539)) ([b9dfaee](https://github.com/feathersjs/feathers/commit/b9dfaee834b13864c1ed4f2f6a244eb5bb70395b))
52
+
53
+
54
+
55
+
56
+
57
+ # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12)
58
+
59
+
60
+ ### Features
61
+
62
+ * **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159))
63
+
64
+
65
+
66
+
67
+
68
+ # [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
69
+
70
+
71
+ ### Bug Fixes
72
+
73
+ * missing express types for Request, Response ([#2498](https://github.com/feathersjs/feathers/issues/2498)) ([ee67131](https://github.com/feathersjs/feathers/commit/ee67131bbaa24c54d3d781bdf8820015759ac488))
74
+ * **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110))
75
+
76
+
77
+ ### Features
78
+
79
+ * **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b))
80
+ * **core:** Improve legacy hooks integration ([08c8b40](https://github.com/feathersjs/feathers/commit/08c8b40999bf3889c61a4d4fad97a2c4f78bafc9))
81
+
82
+
83
+
84
+
85
+
86
+ # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13)
87
+
88
+ **Note:** Version bump only for package @feathersjs/express
89
+
90
+
91
+
92
+
93
+
94
+ # [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13)
95
+
96
+ **Note:** Version bump only for package @feathersjs/express
97
+
98
+
99
+
100
+
101
+
102
+ # [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12)
103
+
104
+ **Note:** Version bump only for package @feathersjs/express
105
+
106
+
107
+
108
+
109
+
110
+ # [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06)
111
+
112
+ **Note:** Version bump only for package @feathersjs/express
113
+
114
+
115
+
116
+
117
+
118
+ # [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19)
119
+
120
+ **Note:** Version bump only for package @feathersjs/express
121
+
122
+
123
+
124
+
125
+
126
+ # [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09)
127
+
128
+ **Note:** Version bump only for package @feathersjs/express
129
+
130
+
131
+
132
+
133
+
134
+ # [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09)
135
+
136
+ **Note:** Version bump only for package @feathersjs/express
137
+
138
+
139
+
140
+
141
+
142
+ # [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09)
143
+
144
+ **Note:** Version bump only for package @feathersjs/express
145
+
146
+
147
+
148
+
149
+
150
+ # [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08)
151
+
152
+ **Note:** Version bump only for package @feathersjs/express
153
+
154
+
155
+
156
+
157
+
158
+ # [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23)
159
+
160
+ **Note:** Version bump only for package @feathersjs/express
161
+
162
+
163
+
164
+
165
+
166
+ # [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13)
167
+
168
+
169
+ ### Features
170
+
171
+ * **koa:** KoaJS transport adapter ([#2315](https://github.com/feathersjs/feathers/issues/2315)) ([2554b57](https://github.com/feathersjs/feathers/commit/2554b57cf05731df58feeba9c12faab18e442107))
172
+
173
+
174
+
175
+
176
+
177
+ # [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21)
178
+
179
+
180
+ ### Bug Fixes
181
+
182
+ * **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897))
183
+
184
+
185
+ ### Features
186
+
187
+ * **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a))
188
+
189
+
190
+
191
+
192
+
6
193
  # [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06)
7
194
 
8
195
  **Note:** Version bump only for package @feathersjs/express
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Feathers
3
+ Copyright (c) 2022 Feathers
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @feathersjs/express
2
2
 
3
3
  [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
4
- [![Dependency Status](https://img.shields.io/david/feathersjs/feathers.svg?style=flat-square&path=packages/express)](https://david-dm.org/feathersjs/feathers?path=packages/express)
5
4
  [![Download Status](https://img.shields.io/npm/dm/@feathersjs/express.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/express)
5
+ [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx)
6
6
 
7
7
  > Feathers Express framework bindings and REST provider
8
8
 
@@ -18,6 +18,6 @@ Refer to the [Feathers Express API documentation](https://docs.feathersjs.com/ap
18
18
 
19
19
  ## License
20
20
 
21
- Copyright (c) 2021 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
21
+ Copyright (c) 2022 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
22
22
 
23
23
  Licensed under the [MIT license](LICENSE).
@@ -1,8 +1,7 @@
1
- import { NextFunction, RequestHandler } from 'express';
2
- declare type StrategyOptions = {
1
+ import { RequestHandler } from 'express';
2
+ export declare type AuthenticationSettings = {
3
3
  service?: string;
4
- strategies: string[];
4
+ strategies?: string[];
5
5
  };
6
- export declare function parseAuthentication(settings?: any): RequestHandler;
7
- export declare function authenticate(_settings: string | StrategyOptions, ..._strategies: string[]): (_req: Request, _res: Response, next: NextFunction) => void;
8
- export {};
6
+ export declare function parseAuthentication(settings?: AuthenticationSettings): RequestHandler;
7
+ export declare function authenticate(settings: string | AuthenticationSettings, ...strategies: string[]): RequestHandler;
@@ -1,59 +1,45 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.authenticate = exports.parseAuthentication = void 0;
7
- const debug_1 = __importDefault(require("debug"));
8
- const lodash_1 = require("lodash");
9
- const debug = debug_1.default('@feathersjs/express/authentication');
10
- const normalizeStrategy = (_settings, ..._strategies) => typeof _settings === 'string'
11
- ? { strategies: lodash_1.flatten([_settings, ..._strategies]) }
12
- : _settings;
4
+ const commons_1 = require("@feathersjs/commons");
5
+ const authentication_1 = require("@feathersjs/authentication");
6
+ const debug = (0, commons_1.createDebug)('@feathersjs/express/authentication');
7
+ const toHandler = (func) => {
8
+ return (req, res, next) => func(req, res, next).catch(error => next(error));
9
+ };
13
10
  function parseAuthentication(settings = {}) {
14
- return function (req, res, next) {
11
+ return toHandler(async (req, res, next) => {
12
+ var _a;
15
13
  const app = req.app;
16
- const service = app.defaultAuthentication ? app.defaultAuthentication(settings.service) : null;
17
- if (service === null) {
14
+ const service = (_a = app.defaultAuthentication) === null || _a === void 0 ? void 0 : _a.call(app, settings.service);
15
+ if (!service) {
18
16
  return next();
19
17
  }
20
18
  const config = service.configuration;
21
- const authStrategies = config.parseStrategies || config.authStrategies || [];
19
+ const authStrategies = settings.strategies || config.parseStrategies || config.authStrategies || [];
22
20
  if (authStrategies.length === 0) {
23
21
  debug('No `authStrategies` or `parseStrategies` found in authentication configuration');
24
22
  return next();
25
23
  }
26
- service.parse(req, res, ...authStrategies)
27
- .then((authentication) => {
28
- if (authentication) {
29
- debug('Parsed authentication from HTTP header', authentication);
30
- lodash_1.merge(req, {
31
- authentication,
32
- feathers: { authentication }
33
- });
34
- }
35
- next();
36
- }).catch(next);
37
- };
24
+ const authentication = await service.parse(req, res, ...authStrategies);
25
+ if (authentication) {
26
+ debug('Parsed authentication from HTTP header', authentication);
27
+ req.feathers = { ...req.feathers, authentication };
28
+ }
29
+ return next();
30
+ });
38
31
  }
39
32
  exports.parseAuthentication = parseAuthentication;
40
- function authenticate(_settings, ..._strategies) {
41
- const settings = normalizeStrategy(_settings, ..._strategies);
42
- if (!Array.isArray(settings.strategies) || settings.strategies.length === 0) {
43
- throw new Error('\'authenticate\' middleware requires at least one strategy name');
44
- }
45
- return (_req, _res, next) => {
46
- const req = _req;
47
- const { app, authentication } = req;
48
- const service = app.defaultAuthentication(settings.service);
49
- debug('Authenticating with Express middleware and strategies', settings.strategies);
50
- service.authenticate(authentication, req.feathers, ...settings.strategies)
51
- .then((authResult) => {
52
- debug('Merging request with', authResult);
53
- lodash_1.merge(req, authResult);
54
- next();
55
- }).catch(next);
56
- };
33
+ function authenticate(settings, ...strategies) {
34
+ const hook = (0, authentication_1.authenticate)(settings, ...strategies);
35
+ return toHandler(async (req, _res, next) => {
36
+ const app = req.app;
37
+ const params = req.feathers;
38
+ const context = { app, params };
39
+ await hook(context);
40
+ req.feathers = context.params;
41
+ return next();
42
+ });
57
43
  }
58
44
  exports.authenticate = authenticate;
59
45
  //# sourceMappingURL=authentication.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.js","sourceRoot":"","sources":["../src/authentication.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,mCAAwC;AAGxC,MAAM,KAAK,GAAG,eAAK,CAAC,oCAAoC,CAAC,CAAC;AAO1D,MAAM,iBAAiB,GAAG,CAAC,SAAiC,EAAE,GAAG,WAAqB,EAAE,EAAE,CACxF,OAAO,SAAS,KAAK,QAAQ;IAC3B,CAAC,CAAC,EAAE,UAAU,EAAE,gBAAO,CAAC,CAAE,SAAS,EAAE,GAAG,WAAW,CAAE,CAAC,EAAE;IACxD,CAAC,CAAC,SAAS,CAAC;AAEhB,SAAgB,mBAAmB,CAAE,WAAgB,EAAE;IACrD,OAAO,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI;QAC7B,MAAM,GAAG,GAAG,GAAG,CAAC,GAAU,CAAC;QAC3B,MAAM,OAAO,GAAG,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,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1,39 +1,44 @@
1
1
  /// <reference types="node" />
2
2
  import http from 'http';
3
3
  import express, { Express } from 'express';
4
- import { Application as FeathersApplication, Params as FeathersParams, HookContext, ServiceMethods, ServiceInterface } from '@feathersjs/feathers';
5
- interface ExpressUseHandler<T, ServiceTypes> {
6
- <L extends keyof ServiceTypes & string>(path: L, ...middlewareOrService: (Express | express.RequestHandler | (keyof any extends keyof ServiceTypes ? ServiceInterface<any> : ServiceTypes[L]))[]): T;
7
- (path: RegExp, ...expressHandlers: express.RequestHandler[]): T;
4
+ import { Application as FeathersApplication, Params as FeathersParams, HookContext, ServiceMethods, ServiceInterface, RouteLookup } from '@feathersjs/feathers';
5
+ interface ExpressUseHandler<T, Services> {
6
+ <L extends keyof Services & string>(path: L, ...middlewareOrService: (Express | express.RequestHandler | express.RequestHandler[] | (keyof any extends keyof Services ? ServiceInterface : Services[L]))[]): T;
7
+ (path: string | RegExp, ...expressHandlers: express.RequestHandler[]): T;
8
8
  (...expressHandlers: express.RequestHandler[]): T;
9
9
  (handler: Express | express.ErrorRequestHandler): T;
10
10
  }
11
- export interface ExpressOverrides<ServiceTypes> {
11
+ export interface ExpressOverrides<Services> {
12
12
  listen(port: number, hostname: string, backlog: number, callback?: () => void): Promise<http.Server>;
13
13
  listen(port: number, hostname: string, callback?: () => void): Promise<http.Server>;
14
14
  listen(port: number | string | any, callback?: () => void): Promise<http.Server>;
15
15
  listen(callback?: () => void): Promise<http.Server>;
16
- use: ExpressUseHandler<this, ServiceTypes>;
16
+ use: ExpressUseHandler<this, Services>;
17
+ server: http.Server;
17
18
  }
18
- export declare type Application<ServiceTypes = any, AppSettings = any> = Omit<Express, 'listen' | 'use'> & FeathersApplication<ServiceTypes, AppSettings> & ExpressOverrides<ServiceTypes>;
19
+ export declare type Application<Services = any, Settings = any> = Omit<Express, 'listen' | 'use' | 'get' | 'set'> & FeathersApplication<Services, Settings> & ExpressOverrides<Services>;
19
20
  declare module '@feathersjs/feathers/lib/declarations' {
20
21
  interface ServiceOptions {
21
- middleware?: {
22
- before: express.RequestHandler[];
23
- after: express.RequestHandler[];
22
+ express?: {
23
+ before?: express.RequestHandler[];
24
+ after?: express.RequestHandler[];
25
+ composed?: express.RequestHandler;
24
26
  };
25
27
  }
26
28
  }
27
29
  declare module 'express-serve-static-core' {
28
30
  interface Request {
29
- feathers?: Partial<FeathersParams>;
31
+ feathers?: Partial<FeathersParams> & {
32
+ [key: string]: any;
33
+ };
34
+ lookup?: RouteLookup;
30
35
  }
31
36
  interface Response {
32
37
  data?: any;
33
38
  hook?: HookContext;
34
39
  }
35
40
  interface IRouterMatcher<T> {
36
- <P extends Params = ParamsDictionary, ResBody = any, ReqBody = any>(path: PathParams, ...handlers: (RequestHandler<P, ResBody, ReqBody> | Partial<ServiceMethods<any, any>> | Application)[]): T;
41
+ <P extends Params = ParamsDictionary, ResBody = any, ReqBody = any>(path: PathParams, ...handlers: (RequestHandler<P, ResBody, ReqBody> | Partial<ServiceMethods> | Application)[]): T;
37
42
  }
38
43
  }
39
44
  export {};
package/lib/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import express, { Express, static as _static, json, raw, text, urlencoded, query } from 'express';
1
+ import { Express } from 'express';
2
2
  import { Application as FeathersApplication } from '@feathersjs/feathers';
3
3
  import { Application } from './declarations';
4
- import { errorHandler, notFound } from './handlers';
5
- import { parseAuthentication, authenticate } from './authentication';
6
- export { _static as static, json, raw, text, urlencoded, query, errorHandler, notFound, express as original, authenticate, parseAuthentication };
7
- export * from './rest';
4
+ export { default as original, static, static as serveStatic, json, raw, text, urlencoded, query } from 'express';
5
+ export * from './authentication';
8
6
  export * from './declarations';
7
+ export * from './handlers';
8
+ export * from './rest';
9
9
  export default function feathersExpress<S = any, C = any>(feathersApp?: FeathersApplication<S, C>, expressApp?: Express): Application<S, C>;
package/lib/index.js CHANGED
@@ -1,69 +1,52 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
8
12
  }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
15
  };
24
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
25
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
26
- return new (P || (P = Promise))(function (resolve, reject) {
27
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
28
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
29
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
30
- step((generator = generator.apply(thisArg, _arguments || [])).next());
31
- });
32
- };
33
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
34
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
35
18
  };
36
19
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.parseAuthentication = exports.authenticate = exports.original = exports.notFound = exports.errorHandler = exports.query = exports.urlencoded = exports.text = exports.raw = exports.json = exports.static = void 0;
38
- const debug_1 = __importDefault(require("debug"));
39
- const express_1 = __importStar(require("express"));
40
- exports.original = express_1.default;
41
- Object.defineProperty(exports, "static", { enumerable: true, get: function () { return express_1.static; } });
42
- Object.defineProperty(exports, "json", { enumerable: true, get: function () { return express_1.json; } });
43
- Object.defineProperty(exports, "raw", { enumerable: true, get: function () { return express_1.raw; } });
44
- Object.defineProperty(exports, "text", { enumerable: true, get: function () { return express_1.text; } });
45
- Object.defineProperty(exports, "urlencoded", { enumerable: true, get: function () { return express_1.urlencoded; } });
46
- Object.defineProperty(exports, "query", { enumerable: true, get: function () { return express_1.query; } });
20
+ exports.query = exports.urlencoded = exports.text = exports.raw = exports.json = exports.serveStatic = exports.static = exports.original = void 0;
21
+ const express_1 = __importDefault(require("express"));
47
22
  const feathers_1 = require("@feathersjs/feathers");
48
- const handlers_1 = require("./handlers");
49
- Object.defineProperty(exports, "errorHandler", { enumerable: true, get: function () { return handlers_1.errorHandler; } });
50
- Object.defineProperty(exports, "notFound", { enumerable: true, get: function () { return handlers_1.notFound; } });
51
- const authentication_1 = require("./authentication");
52
- Object.defineProperty(exports, "parseAuthentication", { enumerable: true, get: function () { return authentication_1.parseAuthentication; } });
53
- Object.defineProperty(exports, "authenticate", { enumerable: true, get: function () { return authentication_1.authenticate; } });
54
- __exportStar(require("./rest"), exports);
23
+ const transport_commons_1 = require("@feathersjs/transport-commons");
24
+ const commons_1 = require("@feathersjs/commons");
25
+ var express_2 = require("express");
26
+ Object.defineProperty(exports, "original", { enumerable: true, get: function () { return __importDefault(express_2).default; } });
27
+ Object.defineProperty(exports, "static", { enumerable: true, get: function () { return express_2.static; } });
28
+ Object.defineProperty(exports, "serveStatic", { enumerable: true, get: function () { return express_2.static; } });
29
+ Object.defineProperty(exports, "json", { enumerable: true, get: function () { return express_2.json; } });
30
+ Object.defineProperty(exports, "raw", { enumerable: true, get: function () { return express_2.raw; } });
31
+ Object.defineProperty(exports, "text", { enumerable: true, get: function () { return express_2.text; } });
32
+ Object.defineProperty(exports, "urlencoded", { enumerable: true, get: function () { return express_2.urlencoded; } });
33
+ Object.defineProperty(exports, "query", { enumerable: true, get: function () { return express_2.query; } });
34
+ __exportStar(require("./authentication"), exports);
55
35
  __exportStar(require("./declarations"), exports);
56
- const debug = debug_1.default('@feathersjs/express');
57
- function feathersExpress(feathersApp, expressApp = express_1.default()) {
36
+ __exportStar(require("./handlers"), exports);
37
+ __exportStar(require("./rest"), exports);
38
+ const debug = (0, commons_1.createDebug)('@feathersjs/express');
39
+ function feathersExpress(feathersApp, expressApp = (0, express_1.default)()) {
58
40
  if (!feathersApp) {
59
41
  return expressApp;
60
42
  }
61
43
  if (typeof feathersApp.setup !== 'function') {
62
44
  throw new Error('@feathersjs/express requires a valid Feathers application instance');
63
45
  }
64
- const { use, listen } = expressApp;
65
- // A mixin that provides the extended functionality
66
- const mixin = {
46
+ const app = expressApp;
47
+ const { use: expressUse, listen: expressListen } = expressApp;
48
+ const { use: feathersUse, teardown: feathersTeardown } = feathersApp;
49
+ Object.assign(app, {
67
50
  use(location, ...rest) {
68
51
  let service;
69
52
  let options = {};
@@ -89,33 +72,50 @@ function feathersExpress(feathersApp, expressApp = express_1.default()) {
89
72
  // Check for service (any object with at least one service method)
90
73
  if (hasMethod(['handle', 'set']) || !hasMethod(feathers_1.defaultServiceMethods)) {
91
74
  debug('Passing app.use call to Express app');
92
- return use.call(this, location, ...rest);
75
+ return expressUse.call(this, location, ...rest);
93
76
  }
94
77
  debug('Registering service with middleware', middleware);
95
78
  // Since this is a service, call Feathers `.use`
96
- feathersApp.use.call(this, location, service, Object.assign(Object.assign({}, options), { middleware }));
79
+ feathersUse.call(this, location, service, {
80
+ ...options,
81
+ express: middleware
82
+ });
97
83
  return this;
98
84
  },
99
- listen(...args) {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- const server = listen.call(this, ...args);
102
- yield this.setup(server);
103
- debug('Feathers application listening');
104
- return server;
105
- });
85
+ async listen(...args) {
86
+ const server = expressListen.call(this, ...args);
87
+ this.server = server;
88
+ await this.setup(server);
89
+ debug('Feathers application listening');
90
+ return server;
91
+ },
92
+ async teardown(server) {
93
+ return feathersTeardown.call(this, server).then(() => new Promise((resolve, reject) => this.server.close(e => e ? reject(e) : resolve(this))));
106
94
  }
95
+ });
96
+ const appDescriptors = {
97
+ ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(app)),
98
+ ...Object.getOwnPropertyDescriptors(app)
99
+ };
100
+ const newDescriptors = {
101
+ ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(feathersApp)),
102
+ ...Object.getOwnPropertyDescriptors(feathersApp)
107
103
  };
108
- const feathersDescriptors = Object.assign(Object.assign({}, Object.getOwnPropertyDescriptors(Object.getPrototypeOf(feathersApp))), Object.getOwnPropertyDescriptors(feathersApp));
109
104
  // Copy all non-existing properties (including non-enumerables)
110
105
  // that don't already exist on the Express app
111
- Object.keys(feathersDescriptors).forEach(prop => {
112
- const feathersProp = feathersDescriptors[prop];
113
- const expressProp = Object.getOwnPropertyDescriptor(expressApp, prop);
114
- if (expressProp === undefined && feathersProp !== undefined) {
115
- Object.defineProperty(expressApp, prop, feathersProp);
106
+ Object.keys(newDescriptors).forEach(prop => {
107
+ const appProp = appDescriptors[prop];
108
+ const newProp = newDescriptors[prop];
109
+ if (appProp === undefined && newProp !== undefined) {
110
+ Object.defineProperty(expressApp, prop, newProp);
116
111
  }
117
112
  });
118
- return Object.assign(expressApp, mixin);
113
+ 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
+ return app;
119
119
  }
120
120
  exports.default = feathersExpress;
121
121
  if (typeof module !== 'undefined') {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAO,MAAM,KAAK,WAAW,EAAE;IACjC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;CACjE"}
package/lib/rest.d.ts CHANGED
@@ -1,21 +1,9 @@
1
- import { HookContext } from '@feathersjs/hooks';
2
- import { NullableId, Params } from '@feathersjs/feathers';
3
- import { Request, Response, NextFunction, RequestHandler } from 'express';
4
- export declare const METHOD_HEADER = "x-service-method";
5
- export interface ServiceParams {
6
- id: NullableId;
7
- data: any;
8
- params: Params;
9
- }
10
- export declare type ServiceCallback = (req: Request, res: Response, options: ServiceParams) => Promise<HookContext | any>;
11
- export declare const statusCodes: {
12
- created: number;
13
- noContent: number;
14
- methodNotAllowed: number;
15
- success: number;
1
+ import { RequestHandler } from 'express';
2
+ import { AuthenticationSettings } from './authentication';
3
+ import { Application } from './declarations';
4
+ export declare const formatter: RequestHandler;
5
+ export declare type RestOptions = {
6
+ formatter?: RequestHandler;
7
+ authentication?: AuthenticationSettings;
16
8
  };
17
- export declare const feathersParams: (req: Request, _res: Response, next: NextFunction) => void;
18
- export declare const formatter: (_req: Request, res: Response, next: NextFunction) => void;
19
- export declare const serviceMiddleware: (callback: ServiceCallback) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
20
- export declare const serviceMethodHandler: (service: any, methodName: string, getArgs: (opts: ServiceParams) => any[], headerOverride?: string) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
21
- export declare function rest(handler?: RequestHandler): (this: any, app: any) => void;
9
+ export declare const rest: (options?: RestOptions | RequestHandler) => (app: Application) => void;