@midwayjs/web 3.0.0-beta.8 → 3.0.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # midway-web
1
+ # @midwayjs/web
2
2
 
3
- [![Package Quality](http://npm.packagequality.com/shield/midway-web.svg)](http://packagequality.com/#?package=midway-web)
3
+ [![Package Quality](http://npm.packagequality.com/shield/@midwayjs/web.svg)](http://packagequality.com/#?package=@midwayjs/web)
4
4
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)
5
5
 
6
6
  this is a sub package for midway.
package/config/plugin.js CHANGED
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports = {
4
+ onerror: true,
5
+ security: true,
4
6
  static: false,
5
7
  development: false,
6
8
  watcher: false,
7
- onerror: true,
8
- multipart: true,
9
- security: true,
9
+ multipart: false,
10
10
  logrotator: false,
11
11
  view: false,
12
12
  schedule: false,
13
+ i18n: false,
13
14
  };
package/dist/base.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createEggAgent = exports.createEggApplication = exports.createAgentWorkerLoader = exports.createAppWorkerLoader = void 0;
4
4
  const utils_1 = require("./utils");
5
- const extend = require("extend2");
6
5
  const core_1 = require("@midwayjs/core");
7
6
  const path_1 = require("path");
8
7
  const fs_1 = require("fs");
@@ -70,7 +69,7 @@ const createAppWorkerLoader = () => {
70
69
  if (!this.appInfo) {
71
70
  const appInfo = super.getAppInfo();
72
71
  // ROOT == HOME in prod env
73
- this.appInfo = extend(true, appInfo, {
72
+ this.appInfo = (0, core_1.extend)(true, appInfo, {
74
73
  root: appInfo.env === 'local' || appInfo.env === 'unittest'
75
74
  ? this.appDir
76
75
  : appInfo.root,
@@ -185,7 +184,7 @@ const createAgentWorkerLoader = () => {
185
184
  if (!this.appInfo) {
186
185
  const appInfo = super.getAppInfo();
187
186
  // ROOT == HOME in prod env
188
- this.appInfo = extend(true, appInfo, {
187
+ this.appInfo = (0, core_1.extend)(true, appInfo, {
189
188
  root: appInfo.env === 'local' || appInfo.env === 'unittest'
190
189
  ? this.appDir
191
190
  : appInfo.root,
@@ -5,9 +5,7 @@ import { EggRouter } from '@eggjs/router';
5
5
  import { Application, Context, EggLogger } from 'egg';
6
6
  declare class EggControllerGenerator extends WebControllerGenerator<EggRouter> {
7
7
  readonly app: any;
8
- readonly applicationContext: any;
9
- readonly logger: any;
10
- constructor(app: any, applicationContext: any, logger: any);
8
+ constructor(app: any);
11
9
  createRouter(routerOptions: any): EggRouter;
12
10
  generateController(routeInfo: RouterInfo): (ctx: any, next: any) => Promise<void>;
13
11
  }
@@ -29,7 +27,7 @@ export declare class MidwayWebFramework extends BaseFramework<Application, Conte
29
27
  run(): Promise<void>;
30
28
  getLogger(name?: string): any;
31
29
  setContextLoggerClass(BaseContextLogger: any): void;
32
- generateMiddleware(middlewareId: string): Promise<any>;
30
+ generateMiddleware(middlewareId: any): Promise<any>;
33
31
  beforeStop(): Promise<void>;
34
32
  }
35
33
  export {};
@@ -19,11 +19,9 @@ const util_1 = require("util");
19
19
  const logger_2 = require("../logger");
20
20
  const debug = (0, util_1.debuglog)('midway:debug');
21
21
  class EggControllerGenerator extends core_1.WebControllerGenerator {
22
- constructor(app, applicationContext, logger) {
23
- super(applicationContext, decorator_1.MidwayFrameworkType.WEB, logger);
22
+ constructor(app) {
23
+ super(app);
24
24
  this.app = app;
25
- this.applicationContext = applicationContext;
26
- this.logger = logger;
27
25
  }
28
26
  createRouter(routerOptions) {
29
27
  const router = new router_1.EggRouter(routerOptions, this.app);
@@ -71,13 +69,20 @@ let MidwayWebFramework = class MidwayWebFramework extends core_1.BaseFramework {
71
69
  if (!this.isClusterMode) {
72
70
  await this.initSingleProcessEgg();
73
71
  }
72
+ // not found middleware
73
+ const notFound = async (ctx, next) => {
74
+ await next();
75
+ if (!ctx._matchedRoute) {
76
+ throw new core_1.httpError.NotFoundError();
77
+ }
78
+ };
74
79
  // insert error handler
75
80
  const midwayRootMiddleware = async (ctx, next) => {
76
81
  // this.app.createAnonymousContext(ctx);
77
- await (await this.getMiddleware())(ctx, next);
82
+ await (await this.applyMiddleware(notFound))(ctx, next);
78
83
  };
79
84
  this.app.use(midwayRootMiddleware);
80
- this.generator = new EggControllerGenerator(this.app, this.applicationContext, this.appLogger);
85
+ this.generator = new EggControllerGenerator(this.app);
81
86
  this.overwriteApplication('app');
82
87
  await new Promise(resolve => {
83
88
  this.app.once('application-ready', () => {
@@ -7,7 +7,7 @@ export interface IMidwayWebBaseApplication {
7
7
  applicationContext: IMidwayContainer;
8
8
  getLogger(name?: string): ILogger;
9
9
  getCoreLogger(): ILogger;
10
- generateMiddleware?(middlewareId: string): Promise<Middleware<DefaultState, EggContext>>;
10
+ generateMiddleware?(middlewareId: any): Promise<Middleware<DefaultState, EggContext>>;
11
11
  createLogger(name: string, options: LoggerOptions): ILogger;
12
12
  }
13
13
  declare module 'egg' {
package/dist/logger.js CHANGED
@@ -7,7 +7,6 @@ const fs_1 = require("fs");
7
7
  const utils_1 = require("./utils");
8
8
  const os = require("os");
9
9
  const core_1 = require("@midwayjs/core");
10
- const extend = require("extend2");
11
10
  const util_1 = require("util");
12
11
  const debug = (0, util_1.debuglog)('midway:debug');
13
12
  const isWindows = os.platform() === 'win32';
@@ -97,7 +96,7 @@ class MidwayLoggers extends Map {
97
96
  },
98
97
  };
99
98
  const midwayLoggerConfig = loggerService.transformEggLogger(options);
100
- extend(true, options, midwayLoggerConfig);
99
+ (0, core_1.extend)(true, options, midwayLoggerConfig);
101
100
  if ((_a = options === null || options === void 0 ? void 0 : options.midwayLogger) === null || _a === void 0 ? void 0 : _a.clients) {
102
101
  // 从 egg 过来,这里有可能没有 dir
103
102
  if (!((_b = options.midwayLogger['default']) === null || _b === void 0 ? void 0 : _b.dir)) {
package/dist/utils.js CHANGED
@@ -117,12 +117,12 @@ async function initializeAgentApplicationContext(agent, globalOptions) {
117
117
  const aspectService = await applicationContext.getAsync(core_1.MidwayAspectService, [applicationContext]);
118
118
  // init decorator service
119
119
  const decoratorService = await applicationContext.getAsync(core_1.MidwayDecoratorService, [applicationContext]);
120
- if (!globalOptions.configurationModule) {
121
- globalOptions.configurationModule = [
120
+ if (!globalOptions.imports) {
121
+ globalOptions.imports = [
122
122
  (0, core_1.safeRequire)((0, path_1.join)(globalOptions.baseDir, 'configuration')),
123
123
  ];
124
124
  }
125
- for (const configurationModule of [].concat(globalOptions.configurationModule)) {
125
+ for (const configurationModule of [].concat(globalOptions.imports)) {
126
126
  // load configuration and component
127
127
  applicationContext.load(configurationModule);
128
128
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@midwayjs/web",
3
- "version": "3.0.0-beta.8",
3
+ "version": "3.0.2",
4
4
  "description": "Midway Web Framework for Egg.js",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "test": "node --require=ts-node/register ../../node_modules/.bin/jest",
10
- "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --coverage --forceExit",
9
+ "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
10
+ "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
11
11
  "link": "npm link"
12
12
  },
13
13
  "keywords": [
@@ -27,27 +27,26 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
- "@midwayjs/decorator": "^3.0.0-beta.8",
31
- "@midwayjs/mock": "^3.0.0-beta.8",
32
- "dayjs": "^1.10.7",
33
- "egg-logger": "^2.4.2",
34
- "egg-mock": "^3.26.0",
35
- "egg-socket.io": "^4.1.6",
36
- "egg-view-nunjucks": "^2.3.0",
30
+ "@midwayjs/decorator": "^3.0.2",
31
+ "@midwayjs/logger": "^2.14.0",
32
+ "@midwayjs/mock": "^3.0.2",
33
+ "dayjs": "1.10.7",
34
+ "egg-logger": "2.7.1",
35
+ "egg-mock": "4.2.0",
36
+ "egg-socket.io": "4.1.6",
37
+ "egg-view-nunjucks": "2.3.0",
37
38
  "fake-egg": "1.0.0",
38
- "fs-extra": "^8.0.1",
39
- "mm": "3",
40
- "pedding": "^1.1.0",
41
- "react": "^16.13.1",
42
- "react-dom": "^16.13.1"
39
+ "fs-extra": "10.0.0",
40
+ "mm": "3.2.0",
41
+ "pedding": "1.1.0",
42
+ "react": "17.0.2",
43
+ "react-dom": "17.0.2"
43
44
  },
44
45
  "dependencies": {
45
46
  "@eggjs/router": "^2.0.0",
46
- "@midwayjs/core": "^3.0.0-beta.8",
47
- "@midwayjs/logger": "^3.0.0-beta.8",
47
+ "@midwayjs/core": "^3.0.2",
48
48
  "egg": "^2.28.0",
49
- "extend2": "^1.0.0",
50
- "find-up": "^5.0.0",
49
+ "find-up": "5.0.0",
51
50
  "mkdirp": "^1.0.4"
52
51
  },
53
52
  "author": "Harry Chen <czy88840616@gmail.com>",
@@ -58,5 +57,5 @@
58
57
  "engines": {
59
58
  "node": ">=12"
60
59
  },
61
- "gitHead": "bfafbdf8798f48d4daac5dd88ad53c6b2f33c110"
60
+ "gitHead": "ca77247d229978a736e79bb208579c014ed226fc"
62
61
  }