@midwayjs/view 3.0.0-beta.7 → 3.0.1

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,11 +1,227 @@
1
1
  # midway-view
2
2
 
3
- [![Package Quality](http://npm.packagequality.com/shield/@midwayjs/view.svg)](http://packagequality.com/#?package=@midwayjs/view)
4
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)
3
+ Base view component for midway.
5
4
 
6
- this is a sub package for midway.
5
+ ## Install
6
+
7
+ @midwayjs/view don't have build-in view engine, So you should choose a template engine like ejs, and install `@midwayjs/view-ejs`.
8
+ View component will be auto install and enable by import `view-ejs`.
9
+
10
+ ```bash
11
+ $ npm i @midwayjs/view-ejs --save
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ First, import component in `src/configuration.ts`.
17
+
18
+ ```typescript
19
+ import { Configuration } from '@midwayjs/decorator';
20
+ import * as view from '@midwayjs/view-ejs';
21
+ import { join } from 'path'
22
+
23
+ @Configuration({
24
+ imports: [
25
+ // ...
26
+ view
27
+ ],
28
+ importConfigs: [
29
+ join(__dirname, 'config')
30
+ ]
31
+ })
32
+ export class ContainerLifeCycle {
33
+ }
34
+ ```
35
+
36
+ Configure the mapping, the file with `.ejs` extension will be rendered by ejs.
37
+
38
+ ```typescript
39
+ // src/config/config.default.ts
40
+ export const view = {
41
+ defaultViewEngine: 'ejs',
42
+ mapping: {
43
+ '.ejs': 'ejs',
44
+ },
45
+ };
46
+
47
+ // ejs config
48
+ export const ejs = {};
49
+ ```
50
+
51
+ In controller, you can call `ctx.render`.
52
+
53
+ ```typescript
54
+ import { Inject, Provide } from '@midwayjs/decorator';
55
+ import { Context } from '@midwayjs/koa';
56
+
57
+ @Controller('/')
58
+ export class HomeController {
59
+
60
+ @Inject()
61
+ ctx: Context;
62
+
63
+ @Get('/')
64
+ async render(){
65
+ await this.ctx.render('hello.ejs', {
66
+ data: 'world',
67
+ });
68
+ }
69
+ }
70
+ ```
71
+
72
+ ## Use multiple view engine
73
+
74
+ @midwayjs/view support multiple view engine, so you can use more than one template engine in one application.
75
+
76
+ If you want add another template engine like nunjucks, then you can add @midwayjs/view-nunjucks component.
77
+
78
+ Configure the plugin and mapping
79
+
80
+ ```typescript
81
+ // src/config/config.default.ts
82
+ export const view = {
83
+ mapping: {
84
+ '.ejs': 'ejs',
85
+ '.nj': 'nunjucks',
86
+ },
87
+ };
88
+ ```
89
+ You can simply render the file with .nj extension.
90
+
91
+ ```typescript
92
+ await this.ctx.render('user.nj');
93
+ ```
94
+
95
+ ## Write a view engine
96
+
97
+ Create a view engine class first, and implement render and renderString, if the template engine don't support, just throw an error.
98
+
99
+ ```typescript
100
+ // lib/view.ts
101
+ import { Provide } from '@midwayjs/decorator';
102
+
103
+ @Provide()
104
+ export class MyView {
105
+
106
+ @Config('xxxx')
107
+ viewConfig;
108
+
109
+ async render(fullpath, locals) {
110
+ return myengine.render(fullpath, locals);
111
+ }
112
+
113
+ async renderString() { throw new Error('not implement'); }
114
+ };
115
+ ```
116
+
117
+ These methods receive three arguments, `renderString` will pass tpl as the first argument instead of name in `render`.
118
+
119
+ `render(name, locals, viewOptions)`
120
+
121
+ - name: the file path that can resolve from root (`/view` by default)
122
+ - locals: data used by template
123
+ - viewOptions: the view options for each render, it can override the view default config in `config/config.default.js`. Plugin should implement it if it has config.
124
+ When you implement view engine, you will receive this options from `render`, the options contain:
125
+ - root: it will resolve the name to full path, but seperating root and name in viewOptions.
126
+ - name: the original name when call render
127
+ - locals: the original locals when call render
128
+
129
+ `renderString(tpl, locals, viewOptions)`
130
+
131
+ - tpl: the template string instead of the file, using in `renderString`
132
+ - locals: same as `render`
133
+ - viewOptions: same as `render`
134
+
135
+ ### Register
136
+
137
+ After define a view engine, you can register it.
138
+
139
+ ```typescript
140
+ // src/configuration.ts
141
+ import { Configuration, Inject, Provide } from '@midwayjs/decorator';
142
+ import * as koa from '@midwayjs/koa';
143
+ import * as view from '@midwayjs/view';
144
+ import { MyView } from './lib/my';
145
+
146
+ @Configuration({
147
+ imports: [koa, view],
148
+ importConfigs: [join(__dirname, 'config')]
149
+ })
150
+ export class AutoConfiguration {
151
+
152
+ @Inject()
153
+ viewManager: view.ViewManager;
154
+
155
+ async onReady(){
156
+ this.viewManager.use('ejs', MyView);
157
+ }
158
+ }
159
+
160
+ ```
161
+
162
+ You can define a view engine name, normally it's a template name.
163
+
164
+ ## Configuration
165
+
166
+ ### Root
167
+
168
+ Root is `${appDir}/view` by default, but you can define multiple directory.
169
+
170
+ ```typescript
171
+ export default appInfo => {
172
+ const appDir = appInfo.appDir;
173
+ return {
174
+ view: {
175
+ rootDir: {
176
+ default: `${appDir}/view`,
177
+ anotherDir: `${appDir}/view2`
178
+ }
179
+ }
180
+ }
181
+ }
182
+ ```
183
+
184
+ ### defaultExtension
185
+
186
+ When render a file, you should specify a extension that let @midway/view know which engine you want to use. However you can define `defaultExtension` without write the extension.
187
+
188
+ ```typescript
189
+ // src/config/config.default.ts
190
+ export const view = {
191
+ defaultExtension: '.html',
192
+ };
193
+
194
+ // controller
195
+ import { Inject, Provide } from '@midwayjs/decorator';
196
+ import { Context } from '@midwayjs/koa';
197
+
198
+ @Controller('/')
199
+ export class HomeController {
200
+
201
+ @Inject()
202
+ ctx: Context;
203
+
204
+ @Get('/')
205
+ async render(){
206
+ // render user.html
207
+ await this.ctx.render('user');
208
+ }
209
+ }
210
+ ```
211
+
212
+ ### viewEngine and defaultViewEngine
213
+
214
+ If you are using `renderString`, you should specify viewEngine in view config, see example above.
215
+
216
+ However, you can define `defaultViewEngine` without set each time.
217
+
218
+ ```js
219
+ // config/config.default.js
220
+ export const view = {
221
+ defaultViewEngine: 'ejs',
222
+ };
223
+ ```
7
224
 
8
- Document: [https://midwayjs.org/midway](https://midwayjs.org/midway)
9
225
 
10
226
  ## License
11
227
 
@@ -1,3 +1,22 @@
1
- declare const _default: (appInfo: any) => any;
1
+ declare const _default: (appInfo: any) => {
2
+ /**
3
+ * view default config
4
+ * @member Config#view
5
+ * @property {String} [rootDir=${appDir}/view] - give a path to find the file, object.values() got array and find for view file
6
+ * @property {Boolean} [cache=true] - whether cache the file's path
7
+ * @property {String} [defaultExtension] - defaultExtension can be added automatically when there is no extension when call `ctx.render`
8
+ * @property {String} [defaultViewEngine] - set the default view engine if you don't want specify the viewEngine every request.
9
+ * @property {Object} mapping - map the file extension to view engine, such as `{ '.ejs': 'ejs' }`
10
+ */
11
+ view: {
12
+ cache: boolean;
13
+ defaultExtension: string;
14
+ defaultViewEngine: string;
15
+ mapping: {};
16
+ rootDir: {
17
+ default: string;
18
+ };
19
+ };
20
+ };
2
21
  export default _default;
3
22
  //# sourceMappingURL=config.default.d.ts.map
@@ -1,13 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path_1 = require("path");
4
- const extend = require("extend2");
5
- exports.default = appInfo => {
6
- const originConfig = require('egg-view/config/config.default')(appInfo);
7
- return extend(true, originConfig, {
8
- view: {
9
- root: (0, path_1.join)(appInfo.appDir, 'view'),
4
+ exports.default = appInfo => ({
5
+ /**
6
+ * view default config
7
+ * @member Config#view
8
+ * @property {String} [rootDir=${appDir}/view] - give a path to find the file, object.values() got array and find for view file
9
+ * @property {Boolean} [cache=true] - whether cache the file's path
10
+ * @property {String} [defaultExtension] - defaultExtension can be added automatically when there is no extension when call `ctx.render`
11
+ * @property {String} [defaultViewEngine] - set the default view engine if you don't want specify the viewEngine every request.
12
+ * @property {Object} mapping - map the file extension to view engine, such as `{ '.ejs': 'ejs' }`
13
+ */
14
+ view: {
15
+ cache: true,
16
+ defaultExtension: '.html',
17
+ defaultViewEngine: '',
18
+ mapping: {},
19
+ rootDir: {
20
+ default: (0, path_1.join)(appInfo.appDir, 'view'),
10
21
  },
11
- });
12
- };
22
+ },
23
+ });
13
24
  //# sourceMappingURL=config.default.js.map
@@ -1,3 +1,4 @@
1
- declare const _default: any;
2
- export default _default;
1
+ export declare const view: {
2
+ cache: boolean;
3
+ };
3
4
  //# sourceMappingURL=config.local.d.ts.map
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = require('egg-view/config/config.local');
3
+ exports.view = void 0;
4
+ exports.view = {
5
+ cache: false,
6
+ };
4
7
  //# sourceMappingURL=config.local.js.map
@@ -1,5 +1,6 @@
1
+ import { MidwayApplicationManager } from '@midwayjs/core';
1
2
  export declare class ViewConfiguration {
2
- app: any;
3
+ applicationManager: MidwayApplicationManager;
3
4
  onReady(container: any): Promise<void>;
4
5
  }
5
6
  //# sourceMappingURL=configuration.d.ts.map
@@ -11,28 +11,58 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ViewConfiguration = void 0;
13
13
  const decorator_1 = require("@midwayjs/decorator");
14
- const mw_util_1 = require("@midwayjs/mw-util");
15
14
  const DefaultConfig = require("./config/config.default");
16
15
  const LocalConfig = require("./config/config.local");
17
16
  const viewManager_1 = require("./viewManager");
17
+ const core_1 = require("@midwayjs/core");
18
+ const contextView_1 = require("./contextView");
18
19
  let ViewConfiguration = class ViewConfiguration {
19
20
  async onReady(container) {
20
- if (!this.app.config) {
21
- this.app.config = this.app.getConfig();
22
- }
23
- (0, mw_util_1.completeAssign)(this.app.context, require('egg-view/app/extend/context'));
24
- this.app.view = await container.getAsync(viewManager_1.ViewManager);
25
- if (!this.app.toAsyncFunction) {
26
- this.app.toAsyncFunction = method => {
27
- return method;
28
- };
29
- }
21
+ this.applicationManager
22
+ .getApplications(['koa', 'egg', 'faas'])
23
+ .forEach((app) => {
24
+ Object.defineProperties(app.context, {
25
+ /**
26
+ * Render a file, then set to body, the parameter is same as {@link @ContextView#render}
27
+ * @return {Promise} result
28
+ */
29
+ render: {
30
+ value: async function (...args) {
31
+ const contextView = await this.requestContext.getAsync(contextView_1.ContextView);
32
+ return contextView.render(...args).then(body => {
33
+ this.body = body;
34
+ });
35
+ },
36
+ },
37
+ /**
38
+ * Render a file, same as {@link @ContextView#render}
39
+ * @return {Promise} result
40
+ */
41
+ renderView: {
42
+ value: async function (...args) {
43
+ const contextView = await this.requestContext.getAsync(contextView_1.ContextView);
44
+ return contextView.render(...args);
45
+ },
46
+ },
47
+ /**
48
+ * Render template string, same as {@link @ContextView#renderString}
49
+ * @return {Promise} result
50
+ */
51
+ renderString: {
52
+ value: async function (...args) {
53
+ const contextView = await this.requestContext.getAsync(contextView_1.ContextView);
54
+ return contextView.renderString(...args);
55
+ },
56
+ },
57
+ });
58
+ });
59
+ await container.getAsync(viewManager_1.ViewManager);
30
60
  }
31
61
  };
32
62
  __decorate([
33
- (0, decorator_1.App)(),
34
- __metadata("design:type", Object)
35
- ], ViewConfiguration.prototype, "app", void 0);
63
+ (0, decorator_1.Inject)(),
64
+ __metadata("design:type", core_1.MidwayApplicationManager)
65
+ ], ViewConfiguration.prototype, "applicationManager", void 0);
36
66
  ViewConfiguration = __decorate([
37
67
  (0, decorator_1.Configuration)({
38
68
  namespace: 'view',
@@ -0,0 +1,18 @@
1
+ import { ViewManager } from './viewManager';
2
+ import { IViewEngine, RenderOptions } from './interface';
3
+ /**
4
+ * View instance for each request.
5
+ *
6
+ * It will find the view engine, and render it.
7
+ * The view engine should be registered in {@link ViewManager}.
8
+ */
9
+ export declare class ContextView implements IViewEngine {
10
+ viewManager: ViewManager;
11
+ viewConfig: any;
12
+ ctx: any;
13
+ render(name: string, locals?: Record<string, any>, options?: RenderOptions): Promise<string>;
14
+ renderString(tpl: string, locals?: Record<string, any>, options?: RenderOptions): Promise<string>;
15
+ private getViewEngine;
16
+ private setLocals;
17
+ }
18
+ //# sourceMappingURL=contextView.d.ts.map
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ContextView = void 0;
13
+ const viewManager_1 = require("./viewManager");
14
+ const decorator_1 = require("@midwayjs/decorator");
15
+ const assert = require("assert");
16
+ const path_1 = require("path");
17
+ /**
18
+ * View instance for each request.
19
+ *
20
+ * It will find the view engine, and render it.
21
+ * The view engine should be registered in {@link ViewManager}.
22
+ */
23
+ let ContextView = class ContextView {
24
+ async render(name, locals, options) {
25
+ // retrieve fullpath matching name from `config.root`
26
+ const filename = await this.viewManager.resolve(name);
27
+ options = options !== null && options !== void 0 ? options : {};
28
+ options.name = name;
29
+ options.root = filename.replace((0, path_1.normalize)(name), '').replace(/[/\\]$/, '');
30
+ options.locals = locals;
31
+ // get the name of view engine,
32
+ // if viewEngine is specified in options, don't match extension
33
+ let viewEngineName = options.viewEngine;
34
+ if (!viewEngineName) {
35
+ const ext = (0, path_1.extname)(filename);
36
+ viewEngineName = this.viewManager.extMap.get(ext);
37
+ }
38
+ // use the default view engine that is configured if no matching above
39
+ if (!viewEngineName) {
40
+ viewEngineName = this.viewConfig.defaultViewEngine;
41
+ }
42
+ assert(viewEngineName, `Can't find viewEngine for ${filename}`);
43
+ // get view engine and render
44
+ const view = await this.getViewEngine(viewEngineName);
45
+ return await view.render(filename, this.setLocals(locals), options);
46
+ }
47
+ async renderString(tpl, locals, options) {
48
+ var _a;
49
+ options = options !== null && options !== void 0 ? options : {};
50
+ const viewEngineName = (_a = options.viewEngine) !== null && _a !== void 0 ? _a : this.viewConfig.defaultViewEngine;
51
+ assert(viewEngineName, "Can't find viewEngine");
52
+ // get view engine and render
53
+ const view = await this.getViewEngine(viewEngineName);
54
+ return await view.renderString(tpl, this.setLocals(locals), options);
55
+ }
56
+ async getViewEngine(name) {
57
+ // get view engine
58
+ const ViewEngine = this.viewManager.get(name);
59
+ assert(ViewEngine, `Can't find ViewEngine "${name}"`);
60
+ // use view engine to render
61
+ const engine = await this.ctx.requestContext.getAsync(ViewEngine);
62
+ // wrap render and renderString to support both async function and generator function
63
+ if (engine.render) {
64
+ engine.render = decorator_1.Utils.toAsyncFunction(engine.render);
65
+ }
66
+ if (engine.renderString) {
67
+ engine.renderString = decorator_1.Utils.toAsyncFunction(engine.renderString);
68
+ }
69
+ return engine;
70
+ }
71
+ setLocals(locals) {
72
+ return Object.assign({
73
+ ctx: this.ctx,
74
+ request: this.ctx.request,
75
+ }, this.ctx.locals, locals);
76
+ }
77
+ };
78
+ __decorate([
79
+ (0, decorator_1.Inject)(),
80
+ __metadata("design:type", viewManager_1.ViewManager)
81
+ ], ContextView.prototype, "viewManager", void 0);
82
+ __decorate([
83
+ (0, decorator_1.Config)('view'),
84
+ __metadata("design:type", Object)
85
+ ], ContextView.prototype, "viewConfig", void 0);
86
+ __decorate([
87
+ (0, decorator_1.Inject)(),
88
+ __metadata("design:type", Object)
89
+ ], ContextView.prototype, "ctx", void 0);
90
+ ContextView = __decorate([
91
+ (0, decorator_1.Provide)()
92
+ ], ContextView);
93
+ exports.ContextView = ContextView;
94
+ //# sourceMappingURL=contextView.js.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export { ViewConfiguration as Configuration } from './configuration';
2
+ export * from './interface';
3
+ export * from './contextView';
2
4
  export * from './viewManager';
3
5
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -13,5 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.Configuration = void 0;
14
14
  var configuration_1 = require("./configuration");
15
15
  Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.ViewConfiguration; } });
16
+ __exportStar(require("./interface"), exports);
17
+ __exportStar(require("./contextView"), exports);
16
18
  __exportStar(require("./viewManager"), exports);
17
19
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,25 @@
1
+ export interface RenderOptions {
2
+ name?: string;
3
+ root?: string;
4
+ locals?: Record<string, any>;
5
+ viewEngine?: string;
6
+ }
7
+ export interface IViewEngine {
8
+ /**
9
+ * Render a file by view engine, then set to body
10
+ * @param {String} name - the file path based on root
11
+ * @param {Object} [locals] - data used by template
12
+ * @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
13
+ * @return {Promise<String>} result - return a promise with a render result
14
+ */
15
+ render(name: string, locals?: Record<string, any>, options?: RenderOptions): Promise<string>;
16
+ /**
17
+ * Render a template string by view engine
18
+ * @param {String} tpl - template string
19
+ * @param {Object} [locals] - data used by template
20
+ * @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
21
+ * @return {Promise<String>} result - return a promise with a render result
22
+ */
23
+ renderString(tpl: string, locals?: Record<string, any>, options?: RenderOptions): Promise<string>;
24
+ }
25
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=interface.js.map
@@ -1,9 +1,11 @@
1
- export declare class ViewManager {
1
+ import { IViewEngine } from './interface';
2
+ export declare class ViewManager extends Map {
2
3
  app: any;
3
- innerManager: any;
4
- get extMap(): any;
5
- get config(): any;
6
- init(): Promise<void>;
4
+ viewConfig: any;
5
+ config: any;
6
+ extMap: Map<any, any>;
7
+ fileMap: Map<any, any>;
8
+ init(): void;
7
9
  /**
8
10
  * This method can register view engine.
9
11
  *
@@ -18,15 +20,14 @@ export declare class ViewManager {
18
20
  * @param {String} name - the name of view engine
19
21
  * @param {Object} viewEngine - the class of view engine
20
22
  */
21
- use(name: string, viewEngine: any): void;
23
+ use(name: string, viewEngine: new (...args: any[]) => IViewEngine): void;
22
24
  /**
23
25
  * Resolve the path based on the given name,
24
- * if the name is `user.html` and root is `app/view` (by default),
25
- * it will return `app/view/user.html`
26
+ * if the name is `user.html` and root is `view` (by default),
27
+ * it will return `view/user.html`
26
28
  * @param {String} name - the given path name, it's relative to config.root
27
29
  * @return {String} filename - the full path
28
30
  */
29
31
  resolve(name: string): Promise<string>;
30
- get(key: any): any;
31
32
  }
32
33
  //# sourceMappingURL=viewManager.d.ts.map
@@ -10,19 +10,32 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ViewManager = void 0;
13
- const OriginViewManager = require("egg-view/lib/view_manager");
14
13
  const decorator_1 = require("@midwayjs/decorator");
15
- const mw_util_1 = require("@midwayjs/mw-util");
16
- let ViewManager = class ViewManager {
17
- get extMap() {
18
- return this.innerManager.extMap;
14
+ const assert = require("assert");
15
+ const path = require("path");
16
+ const fs_1 = require("fs");
17
+ let ViewManager = class ViewManager extends Map {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.extMap = new Map();
21
+ this.fileMap = new Map();
19
22
  }
20
- get config() {
21
- return this.innerManager.config;
22
- }
23
- async init() {
24
- const mockApp = (0, mw_util_1.createMockApp)(this.app);
25
- this.innerManager = new OriginViewManager(mockApp);
23
+ init() {
24
+ this.config = this.viewConfig;
25
+ const rootSet = new Set(Object.values(this.config.rootDir));
26
+ if (this.config.root) {
27
+ this.config.root.split(/\s*,\s*/g).forEach(filepath => {
28
+ rootSet.add(filepath);
29
+ });
30
+ }
31
+ this.config.root = Array.from(rootSet.values()).filter(filepath => {
32
+ return (0, fs_1.existsSync)(filepath);
33
+ });
34
+ this.extMap = new Map();
35
+ this.fileMap = new Map();
36
+ for (const ext of Object.keys(this.config.mapping)) {
37
+ this.extMap.set(ext, this.config.mapping[ext]);
38
+ }
26
39
  }
27
40
  /**
28
41
  * This method can register view engine.
@@ -39,35 +52,70 @@ let ViewManager = class ViewManager {
39
52
  * @param {Object} viewEngine - the class of view engine
40
53
  */
41
54
  use(name, viewEngine) {
42
- return this.innerManager.use(name, viewEngine);
55
+ assert(name, 'name is required');
56
+ assert(!this.has(name), `${name} has been registered`);
57
+ assert(viewEngine, 'viewEngine is required');
58
+ assert(viewEngine.prototype.render, 'viewEngine should implement `render` method');
59
+ assert(viewEngine.prototype.renderString, 'viewEngine should implement `renderString` method');
60
+ this.set(name, viewEngine);
43
61
  }
44
62
  /**
45
63
  * Resolve the path based on the given name,
46
- * if the name is `user.html` and root is `app/view` (by default),
47
- * it will return `app/view/user.html`
64
+ * if the name is `user.html` and root is `view` (by default),
65
+ * it will return `view/user.html`
48
66
  * @param {String} name - the given path name, it's relative to config.root
49
67
  * @return {String} filename - the full path
50
68
  */
51
69
  async resolve(name) {
52
- return this.innerManager.resolve(name);
53
- }
54
- get(key) {
55
- return this.innerManager.get(key);
70
+ const config = this.config;
71
+ // check cache
72
+ let filename = this.fileMap.get(name);
73
+ if (config.cache && filename)
74
+ return filename;
75
+ // try find it with default extension
76
+ filename = await resolvePath([name, name + config.defaultExtension], config.root);
77
+ assert(filename, `Can't find ${name} from ${config.root.join(',')}`);
78
+ // set cache
79
+ this.fileMap.set(name, filename);
80
+ return filename;
56
81
  }
57
82
  };
58
83
  __decorate([
59
84
  (0, decorator_1.App)(),
60
85
  __metadata("design:type", Object)
61
86
  ], ViewManager.prototype, "app", void 0);
87
+ __decorate([
88
+ (0, decorator_1.Config)('view'),
89
+ __metadata("design:type", Object)
90
+ ], ViewManager.prototype, "viewConfig", void 0);
62
91
  __decorate([
63
92
  (0, decorator_1.Init)(),
64
93
  __metadata("design:type", Function),
65
94
  __metadata("design:paramtypes", []),
66
- __metadata("design:returntype", Promise)
95
+ __metadata("design:returntype", void 0)
67
96
  ], ViewManager.prototype, "init", null);
68
97
  ViewManager = __decorate([
69
98
  (0, decorator_1.Provide)(),
70
99
  (0, decorator_1.Scope)(decorator_1.ScopeEnum.Singleton)
71
100
  ], ViewManager);
72
101
  exports.ViewManager = ViewManager;
102
+ async function resolvePath(names, root) {
103
+ for (const name of names) {
104
+ for (const dir of root) {
105
+ const filename = path.join(dir, name);
106
+ try {
107
+ await fs_1.promises.access(filename, fs_1.constants.R_OK);
108
+ if (inpath(dir, filename)) {
109
+ return filename;
110
+ }
111
+ }
112
+ catch (err) {
113
+ // ignore
114
+ }
115
+ }
116
+ }
117
+ }
118
+ function inpath(parent, sub) {
119
+ return sub.indexOf(parent) > -1;
120
+ }
73
121
  //# sourceMappingURL=viewManager.js.map
package/index.d.ts CHANGED
@@ -1,54 +1,11 @@
1
+ import { IViewEngine } from './dist';
1
2
  export * from './dist/index';
2
3
 
3
- interface RenderOptions {
4
- name?: string;
5
- root?: string;
6
- locals?: Record<string, any>;
7
- viewEngine?: string;
8
- }
9
-
10
4
  declare module '@midwayjs/core/dist/interface' {
11
- interface Context {
12
- /**
13
- * Render a file by view engine, then set to body
14
- * @param {String} name - the file path based on root
15
- * @param {Object} [locals] - data used by template
16
- * @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
17
- * @return {Promise<String>} result - return a promise with a render result
18
- */
19
- render(name: string, locals?: any, options?: RenderOptions): Promise<null>;
20
-
21
- /**
22
- * Render a file by view engine and return it
23
- * @param {String} name - the file path based on root
24
- * @param {Object} [locals] - data used by template
25
- * @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
26
- * @return {Promise<String>} result - return a promise with a render result
27
- */
28
- renderView(
29
- name: string,
30
- locals?: any,
31
- options?: RenderOptions
32
- ): Promise<string>;
33
-
34
- /**
35
- * Render a template string by view engine
36
- * @param {String} tpl - template string
37
- * @param {Object} [locals] - data used by template
38
- * @param {Object} [options] - view options, you can use `options.viewEngine` to specify view engine
39
- * @return {Promise<String>} result - return a promise with a render result
40
- */
41
- renderString(
42
- name: string,
43
- locals?: any,
44
- options?: RenderOptions
45
- ): Promise<string>;
46
- }
47
-
48
5
  interface MidwayConfig {
49
6
  view?: {
50
7
  /**
51
- * give a path to find the file, you can specify multiple path with `,` delimiter
8
+ * give a path to find the file, it will be override rootDir.default
52
9
  */
53
10
  root?: string;
54
11
  /**
@@ -67,6 +24,31 @@ declare module '@midwayjs/core/dist/interface' {
67
24
  * map the file extension to view engine, such as `{ '.ejs': 'ejs' }`
68
25
  */
69
26
  mapping?: Record<string, string>;
27
+ /**
28
+ * give multi-path for root, it can be overwrite or add in different component
29
+ */
30
+ rootDir?: Record<string, string>;
70
31
  };
71
32
  }
72
33
  }
34
+
35
+ declare module '@midwayjs/koa/dist/interface' {
36
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
37
+ interface Context extends IViewEngine {
38
+ //...
39
+ }
40
+ }
41
+
42
+ declare module '@midwayjs/web/dist/interface' {
43
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
44
+ interface Context extends IViewEngine {
45
+ //...
46
+ }
47
+ }
48
+
49
+ declare module '@midwayjs/faas/dist/interface' {
50
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
51
+ interface Context extends IViewEngine {
52
+ //...
53
+ }
54
+ }
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "@midwayjs/view",
3
- "version": "3.0.0-beta.7",
4
- "description": "Midway Component for egg-view",
3
+ "version": "3.0.1",
4
+ "description": "Midway Component for render view",
5
5
  "main": "dist/index.js",
6
6
  "typings": "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
  "ci": "npm run test"
12
12
  },
13
13
  "keywords": [
14
14
  "midway",
15
15
  "component",
16
16
  "midway-view",
17
- "view",
18
- "egg-view"
17
+ "view"
19
18
  ],
20
19
  "author": "",
21
20
  "files": [
@@ -27,16 +26,11 @@
27
26
  "node": ">=12"
28
27
  },
29
28
  "license": "MIT",
30
- "dependencies": {
31
- "@midwayjs/mw-util": "^1.0.0",
32
- "egg-view": "^2.1.3",
33
- "extend2": "^1.0.0"
34
- },
35
29
  "devDependencies": {
36
- "@midwayjs/core": "^3.0.0-beta.7",
37
- "@midwayjs/decorator": "^3.0.0-beta.7",
38
- "@midwayjs/koa": "^3.0.0-beta.7",
39
- "@midwayjs/mock": "^3.0.0-beta.7"
30
+ "@midwayjs/core": "^3.0.1",
31
+ "@midwayjs/decorator": "^3.0.0",
32
+ "@midwayjs/koa": "^3.0.1",
33
+ "@midwayjs/mock": "^3.0.1"
40
34
  },
41
- "gitHead": "24590729121d9110e2d960db5b5e587cf55a1efc"
35
+ "gitHead": "f345b4ed0392e5c3b9e815438ef0a377ad6da076"
42
36
  }
package/CHANGELOG.md DELETED
@@ -1,499 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [3.0.0-beta.7](https://github.com/midwayjs/midway/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2021-12-03)
7
-
8
-
9
- ### Bug Fixes
10
-
11
- * add app.keys ([#1395](https://github.com/midwayjs/midway/issues/1395)) ([c44afc6](https://github.com/midwayjs/midway/commit/c44afc6cc6764a959d1fa7ae04d60099282d156a))
12
-
13
-
14
-
15
-
16
-
17
- # [3.0.0-beta.6](https://github.com/midwayjs/midway/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2021-11-26)
18
-
19
- **Note:** Version bump only for package @midwayjs/view
20
-
21
-
22
-
23
-
24
-
25
- # [3.0.0-beta.5](https://github.com/midwayjs/midway/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-11-25)
26
-
27
- **Note:** Version bump only for package @midwayjs/view
28
-
29
-
30
-
31
-
32
-
33
- # [3.0.0-beta.4](https://github.com/midwayjs/midway/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2021-11-24)
34
-
35
- **Note:** Version bump only for package @midwayjs/view
36
-
37
-
38
-
39
-
40
-
41
- # [3.0.0-beta.3](https://github.com/midwayjs/midway/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2021-11-18)
42
-
43
-
44
- ### Features
45
-
46
- * add component and framework config definition ([#1367](https://github.com/midwayjs/midway/issues/1367)) ([b2fe615](https://github.com/midwayjs/midway/commit/b2fe6157f99659471ff1333eca0b86bb889f61a3))
47
-
48
-
49
-
50
-
51
-
52
- # [3.0.0-beta.2](https://github.com/midwayjs/midway/compare/v3.0.0-beta.1...v3.0.0-beta.2) (2021-11-16)
53
-
54
- **Note:** Version bump only for package @midwayjs/view
55
-
56
-
57
-
58
-
59
-
60
- # [3.0.0-beta.1](https://github.com/midwayjs/midway/compare/v2.12.4...v3.0.0-beta.1) (2021-11-14)
61
-
62
-
63
- ### Features
64
-
65
- * add view, view-ejs and view-nunjucks ([#1308](https://github.com/midwayjs/midway/issues/1308)) ([a00f44b](https://github.com/midwayjs/midway/commit/a00f44bd769052245cd49d49ab417d621bb89caa))
66
-
67
-
68
-
69
-
70
-
71
- ## [2.13.2](https://github.com/midwayjs/midway/compare/v2.13.1...v2.13.2) (2021-09-09)
72
-
73
- **Note:** Version bump only for package @midwayjs/typegoose
74
-
75
-
76
-
77
-
78
-
79
- ## [2.13.1](https://github.com/midwayjs/midway/compare/v2.13.0...v2.13.1) (2021-09-08)
80
-
81
- **Note:** Version bump only for package @midwayjs/typegoose
82
-
83
-
84
-
85
-
86
-
87
- # [2.13.0](https://github.com/midwayjs/midway/compare/v2.12.9...v2.13.0) (2021-09-07)
88
-
89
- **Note:** Version bump only for package @midwayjs/typegoose
90
-
91
-
92
-
93
-
94
-
95
- ## [2.12.9](https://github.com/midwayjs/midway/compare/v2.12.8...v2.12.9) (2021-09-01)
96
-
97
- **Note:** Version bump only for package @midwayjs/typegoose
98
-
99
-
100
-
101
-
102
-
103
- ## [2.12.7](https://github.com/midwayjs/midway/compare/v2.12.6...v2.12.7) (2021-08-22)
104
-
105
- **Note:** Version bump only for package @midwayjs/typegoose
106
-
107
-
108
-
109
-
110
-
111
- ## [2.12.5](https://github.com/midwayjs/midway/compare/v2.12.4...v2.12.5) (2021-08-18)
112
-
113
- **Note:** Version bump only for package @midwayjs/typegoose
114
-
115
-
116
-
117
-
118
-
119
- ## [2.12.3](https://github.com/midwayjs/midway/compare/v2.12.2...v2.12.3) (2021-08-09)
120
-
121
- **Note:** Version bump only for package @midwayjs/typegoose
122
-
123
-
124
-
125
-
126
-
127
- ## [2.12.1](https://github.com/midwayjs/midway/compare/v2.12.0...v2.12.1) (2021-08-01)
128
-
129
- **Note:** Version bump only for package @midwayjs/typegoose
130
-
131
-
132
-
133
-
134
-
135
- # [2.12.0](https://github.com/midwayjs/midway/compare/v2.11.7...v2.12.0) (2021-07-30)
136
-
137
- **Note:** Version bump only for package @midwayjs/typegoose
138
-
139
-
140
-
141
-
142
-
143
- ## [2.11.6](https://github.com/midwayjs/midway/compare/v2.11.5...v2.11.6) (2021-07-16)
144
-
145
- **Note:** Version bump only for package @midwayjs/typegoose
146
-
147
-
148
-
149
-
150
-
151
- ## [2.11.5](https://github.com/midwayjs/midway/compare/v2.11.4...v2.11.5) (2021-07-15)
152
-
153
- **Note:** Version bump only for package @midwayjs/typegoose
154
-
155
-
156
-
157
-
158
-
159
- ## [2.11.4](https://github.com/midwayjs/midway/compare/v2.11.3...v2.11.4) (2021-07-06)
160
-
161
- **Note:** Version bump only for package @midwayjs/typegoose
162
-
163
-
164
-
165
-
166
-
167
- ## [2.11.3](https://github.com/midwayjs/midway/compare/v2.11.2...v2.11.3) (2021-07-02)
168
-
169
-
170
- ### Bug Fixes
171
-
172
- * hide real error when user code throw error ([#1128](https://github.com/midwayjs/midway/issues/1128)) ([e728b0b](https://github.com/midwayjs/midway/commit/e728b0b80956c09cfb856ffe082f44fa29cfeb82))
173
-
174
-
175
-
176
-
177
-
178
- ## [2.11.2](https://github.com/midwayjs/midway/compare/v2.11.1...v2.11.2) (2021-06-28)
179
-
180
- **Note:** Version bump only for package @midwayjs/typegoose
181
-
182
-
183
-
184
-
185
-
186
- ## [2.11.1](https://github.com/midwayjs/midway/compare/v2.11.0...v2.11.1) (2021-06-19)
187
-
188
- **Note:** Version bump only for package @midwayjs/typegoose
189
-
190
-
191
-
192
-
193
-
194
- # [2.11.0](https://github.com/midwayjs/midway/compare/v2.10.19...v2.11.0) (2021-06-10)
195
-
196
- **Note:** Version bump only for package @midwayjs/typegoose
197
-
198
-
199
-
200
-
201
-
202
- ## [2.10.18](https://github.com/midwayjs/midway/compare/v2.10.17...v2.10.18) (2021-05-26)
203
-
204
- **Note:** Version bump only for package @midwayjs/typegoose
205
-
206
-
207
-
208
-
209
-
210
- ## [2.10.14](https://github.com/midwayjs/midway/compare/v2.10.13...v2.10.14) (2021-05-11)
211
-
212
- **Note:** Version bump only for package @midwayjs/typegoose
213
-
214
-
215
-
216
-
217
-
218
- ## [2.10.13](https://github.com/midwayjs/midway/compare/v2.10.12...v2.10.13) (2021-05-08)
219
-
220
- **Note:** Version bump only for package @midwayjs/typegoose
221
-
222
-
223
-
224
-
225
-
226
- ## [2.10.12](https://github.com/midwayjs/midway/compare/v2.10.11...v2.10.12) (2021-05-07)
227
-
228
- **Note:** Version bump only for package @midwayjs/typegoose
229
-
230
-
231
-
232
-
233
-
234
- ## [2.10.11](https://github.com/midwayjs/midway/compare/v2.10.10...v2.10.11) (2021-04-29)
235
-
236
- **Note:** Version bump only for package @midwayjs/typegoose
237
-
238
-
239
-
240
-
241
-
242
- ## [2.10.10](https://github.com/midwayjs/midway/compare/v2.10.9...v2.10.10) (2021-04-24)
243
-
244
- **Note:** Version bump only for package @midwayjs/typegoose
245
-
246
-
247
-
248
-
249
-
250
- ## [2.10.9](https://github.com/midwayjs/midway/compare/v2.10.8...v2.10.9) (2021-04-21)
251
-
252
- **Note:** Version bump only for package @midwayjs/typegoose
253
-
254
-
255
-
256
-
257
-
258
- ## [2.10.8](https://github.com/midwayjs/midway/compare/v2.10.7...v2.10.8) (2021-04-21)
259
-
260
- **Note:** Version bump only for package @midwayjs/typegoose
261
-
262
-
263
-
264
-
265
-
266
- ## [2.10.7](https://github.com/midwayjs/midway/compare/v2.10.6...v2.10.7) (2021-04-17)
267
-
268
-
269
- ### Bug Fixes
270
-
271
- * add event name args ([#986](https://github.com/midwayjs/midway/issues/986)) ([bfd8232](https://github.com/midwayjs/midway/commit/bfd82320aee8600d8fa30bd2821a0e68c80fd755))
272
- * format ([#997](https://github.com/midwayjs/midway/issues/997)) ([456cc14](https://github.com/midwayjs/midway/commit/456cc14513bdb000d1aa3130e9719caf7a8a803f))
273
-
274
-
275
- ### Features
276
-
277
- * add midway task component ([#995](https://github.com/midwayjs/midway/issues/995)) ([befb81d](https://github.com/midwayjs/midway/commit/befb81dee90f01a20bba2c1835e8685cf85a76e7))
278
-
279
-
280
-
281
-
282
-
283
- ## [2.10.6](https://github.com/midwayjs/midway/compare/v2.10.5...v2.10.6) (2021-04-14)
284
-
285
- **Note:** Version bump only for package @midwayjs/typegoose
286
-
287
-
288
-
289
-
290
-
291
- ## [2.10.5](https://github.com/midwayjs/midway/compare/v2.10.4...v2.10.5) (2021-04-13)
292
-
293
- **Note:** Version bump only for package @midwayjs/typegoose
294
-
295
-
296
-
297
-
298
-
299
- ## [2.10.4](https://github.com/midwayjs/midway/compare/v2.10.3...v2.10.4) (2021-04-10)
300
-
301
- **Note:** Version bump only for package @midwayjs/typegoose
302
-
303
-
304
-
305
-
306
-
307
- ## [2.10.3](https://github.com/midwayjs/midway/compare/v2.10.2...v2.10.3) (2021-04-07)
308
-
309
- **Note:** Version bump only for package @midwayjs/typegoose
310
-
311
-
312
-
313
-
314
-
315
- ## [2.10.2](https://github.com/midwayjs/midway/compare/v2.10.1...v2.10.2) (2021-04-05)
316
-
317
- **Note:** Version bump only for package @midwayjs/typegoose
318
-
319
-
320
-
321
-
322
-
323
- # [2.10.0](https://github.com/midwayjs/midway/compare/v2.9.3...v2.10.0) (2021-04-02)
324
-
325
- **Note:** Version bump only for package @midwayjs/typegoose
326
-
327
-
328
-
329
-
330
-
331
- ## [2.9.3](https://github.com/midwayjs/midway/compare/v2.9.2...v2.9.3) (2021-03-30)
332
-
333
- **Note:** Version bump only for package @midwayjs/typegoose
334
-
335
-
336
-
337
-
338
-
339
- ## [2.9.2](https://github.com/midwayjs/midway/compare/v2.9.1...v2.9.2) (2021-03-27)
340
-
341
- **Note:** Version bump only for package @midwayjs/typegoose
342
-
343
-
344
-
345
-
346
-
347
- ## [2.9.1](https://github.com/midwayjs/midway/compare/v2.9.0...v2.9.1) (2021-03-24)
348
-
349
- **Note:** Version bump only for package @midwayjs/typegoose
350
-
351
-
352
-
353
-
354
-
355
- # [2.9.0](https://github.com/midwayjs/midway/compare/v2.8.13...v2.9.0) (2021-03-22)
356
-
357
- **Note:** Version bump only for package @midwayjs/typegoose
358
-
359
-
360
-
361
-
362
-
363
- ## [2.8.13](https://github.com/midwayjs/midway/compare/v2.8.12...v2.8.13) (2021-03-17)
364
-
365
- **Note:** Version bump only for package @midwayjs/typegoose
366
-
367
-
368
-
369
-
370
-
371
- ## [2.8.11](https://github.com/midwayjs/midway/compare/v2.8.10...v2.8.11) (2021-03-12)
372
-
373
- **Note:** Version bump only for package @midwayjs/typegoose
374
-
375
-
376
-
377
-
378
-
379
- ## [2.8.9](https://github.com/midwayjs/midway/compare/v2.8.8...v2.8.9) (2021-03-08)
380
-
381
- **Note:** Version bump only for package @midwayjs/typegoose
382
-
383
-
384
-
385
-
386
-
387
- ## [2.8.8](https://github.com/midwayjs/midway/compare/v2.8.7...v2.8.8) (2021-03-06)
388
-
389
- **Note:** Version bump only for package @midwayjs/typegoose
390
-
391
-
392
-
393
-
394
-
395
- ## [2.8.7](https://github.com/midwayjs/midway/compare/v2.8.6...v2.8.7) (2021-03-04)
396
-
397
- **Note:** Version bump only for package @midwayjs/typegoose
398
-
399
-
400
-
401
-
402
-
403
- ## [2.8.6](https://github.com/midwayjs/midway/compare/v2.8.5...v2.8.6) (2021-03-03)
404
-
405
- **Note:** Version bump only for package @midwayjs/typegoose
406
-
407
-
408
-
409
-
410
-
411
- ## [2.8.5](https://github.com/midwayjs/midway/compare/v2.8.4...v2.8.5) (2021-03-03)
412
-
413
- **Note:** Version bump only for package @midwayjs/typegoose
414
-
415
-
416
-
417
-
418
-
419
- ## [2.8.4](https://github.com/midwayjs/midway/compare/v2.8.3...v2.8.4) (2021-03-03)
420
-
421
- **Note:** Version bump only for package @midwayjs/typegoose
422
-
423
-
424
-
425
-
426
-
427
- ## [2.8.3](https://github.com/midwayjs/midway/compare/v2.8.2...v2.8.3) (2021-03-01)
428
-
429
- **Note:** Version bump only for package @midwayjs/typegoose
430
-
431
-
432
-
433
-
434
-
435
- ## [2.8.2](https://github.com/midwayjs/midway/compare/v2.8.0...v2.8.2) (2021-02-27)
436
-
437
- **Note:** Version bump only for package @midwayjs/typegoose
438
-
439
-
440
-
441
-
442
-
443
- # [2.8.0](https://github.com/midwayjs/midway/compare/v2.7.7...v2.8.0) (2021-02-24)
444
-
445
- **Note:** Version bump only for package @midwayjs/typegoose
446
-
447
-
448
-
449
-
450
-
451
- ## [2.7.7](https://github.com/midwayjs/midway/compare/v2.7.6...v2.7.7) (2021-02-20)
452
-
453
- **Note:** Version bump only for package @midwayjs/typegoose
454
-
455
-
456
-
457
-
458
-
459
- ## [2.7.5](https://github.com/midwayjs/midway/compare/v2.7.4...v2.7.5) (2021-02-08)
460
-
461
- **Note:** Version bump only for package @midwayjs/typegoose
462
-
463
-
464
-
465
-
466
-
467
- ## [2.7.3](https://github.com/midwayjs/midway/compare/v2.7.2...v2.7.3) (2021-02-02)
468
-
469
-
470
- ### Bug Fixes
471
-
472
- * egg socket io missing session middleware ([#835](https://github.com/midwayjs/midway/issues/835)) ([6e605a1](https://github.com/midwayjs/midway/commit/6e605a15b64bf51182b393b68d66d0867c571b94))
473
-
474
-
475
-
476
-
477
-
478
- ## [2.7.2](https://github.com/midwayjs/midway/compare/v2.7.1...v2.7.2) (2021-01-28)
479
-
480
- **Note:** Version bump only for package @midwayjs/typegoose
481
-
482
-
483
-
484
-
485
-
486
- ## [2.7.1](https://github.com/midwayjs/midway/compare/v2.7.0...v2.7.1) (2021-01-28)
487
-
488
- **Note:** Version bump only for package @midwayjs/typegoose
489
-
490
-
491
-
492
-
493
-
494
- # [2.7.0](https://github.com/midwayjs/midway/compare/v2.6.13...v2.7.0) (2021-01-27)
495
-
496
-
497
- ### Features
498
-
499
- * support entry file in bootstrap ([#819](https://github.com/midwayjs/midway/issues/819)) ([49a5ff6](https://github.com/midwayjs/midway/commit/49a5ff662134bdd42dc3a80738b44a05138f8f7c))