@eggjs/core 6.5.0 → 6.6.0-beta.10

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.
Files changed (87) hide show
  1. package/README.md +1 -5
  2. package/dist/base_context_class.d.ts +21 -0
  3. package/dist/base_context_class.js +40 -0
  4. package/dist/egg.d.ts +248 -0
  5. package/dist/egg.js +358 -0
  6. package/dist/index.d.ts +12 -0
  7. package/dist/index.js +12 -0
  8. package/dist/lifecycle.d.ts +84 -0
  9. package/dist/lifecycle.js +280 -0
  10. package/dist/loader/context_loader.d.ts +39 -0
  11. package/dist/loader/context_loader.js +79 -0
  12. package/dist/loader/egg_loader.d.ts +374 -0
  13. package/dist/loader/egg_loader.js +1184 -0
  14. package/dist/loader/file_loader.d.ts +105 -0
  15. package/dist/loader/file_loader.js +198 -0
  16. package/dist/singleton.d.ts +33 -0
  17. package/dist/singleton.js +107 -0
  18. package/{src/types.ts → dist/types.d.ts} +7 -7
  19. package/dist/utils/index.d.ts +19 -0
  20. package/dist/utils/index.js +103 -0
  21. package/dist/utils/sequencify.d.ts +16 -0
  22. package/dist/utils/sequencify.js +46 -0
  23. package/dist/utils/timing.d.ts +24 -0
  24. package/dist/utils/timing.js +85 -0
  25. package/package.json +39 -75
  26. package/dist/commonjs/base_context_class.d.ts +0 -16
  27. package/dist/commonjs/base_context_class.js +0 -41
  28. package/dist/commonjs/egg.d.ts +0 -246
  29. package/dist/commonjs/egg.js +0 -401
  30. package/dist/commonjs/index.d.ts +0 -12
  31. package/dist/commonjs/index.js +0 -32
  32. package/dist/commonjs/lifecycle.d.ts +0 -78
  33. package/dist/commonjs/lifecycle.js +0 -315
  34. package/dist/commonjs/loader/context_loader.d.ts +0 -35
  35. package/dist/commonjs/loader/context_loader.js +0 -110
  36. package/dist/commonjs/loader/egg_loader.d.ts +0 -369
  37. package/dist/commonjs/loader/egg_loader.js +0 -1558
  38. package/dist/commonjs/loader/file_loader.d.ts +0 -100
  39. package/dist/commonjs/loader/file_loader.js +0 -260
  40. package/dist/commonjs/package.json +0 -3
  41. package/dist/commonjs/singleton.d.ts +0 -29
  42. package/dist/commonjs/singleton.js +0 -124
  43. package/dist/commonjs/types.d.ts +0 -53
  44. package/dist/commonjs/types.js +0 -3
  45. package/dist/commonjs/utils/index.d.ts +0 -17
  46. package/dist/commonjs/utils/index.js +0 -117
  47. package/dist/commonjs/utils/sequencify.d.ts +0 -13
  48. package/dist/commonjs/utils/sequencify.js +0 -64
  49. package/dist/commonjs/utils/timing.d.ts +0 -21
  50. package/dist/commonjs/utils/timing.js +0 -106
  51. package/dist/esm/base_context_class.d.ts +0 -16
  52. package/dist/esm/base_context_class.js +0 -37
  53. package/dist/esm/egg.d.ts +0 -246
  54. package/dist/esm/egg.js +0 -388
  55. package/dist/esm/index.d.ts +0 -12
  56. package/dist/esm/index.js +0 -12
  57. package/dist/esm/lifecycle.d.ts +0 -78
  58. package/dist/esm/lifecycle.js +0 -308
  59. package/dist/esm/loader/context_loader.d.ts +0 -35
  60. package/dist/esm/loader/context_loader.js +0 -102
  61. package/dist/esm/loader/egg_loader.d.ts +0 -369
  62. package/dist/esm/loader/egg_loader.js +0 -1551
  63. package/dist/esm/loader/file_loader.d.ts +0 -100
  64. package/dist/esm/loader/file_loader.js +0 -253
  65. package/dist/esm/package.json +0 -3
  66. package/dist/esm/singleton.d.ts +0 -29
  67. package/dist/esm/singleton.js +0 -117
  68. package/dist/esm/types.d.ts +0 -53
  69. package/dist/esm/types.js +0 -2
  70. package/dist/esm/utils/index.d.ts +0 -17
  71. package/dist/esm/utils/index.js +0 -112
  72. package/dist/esm/utils/sequencify.d.ts +0 -13
  73. package/dist/esm/utils/sequencify.js +0 -61
  74. package/dist/esm/utils/timing.d.ts +0 -21
  75. package/dist/esm/utils/timing.js +0 -99
  76. package/dist/package.json +0 -4
  77. package/src/base_context_class.ts +0 -39
  78. package/src/egg.ts +0 -617
  79. package/src/index.ts +0 -14
  80. package/src/lifecycle.ts +0 -438
  81. package/src/loader/context_loader.ts +0 -123
  82. package/src/loader/egg_loader.ts +0 -1984
  83. package/src/loader/file_loader.ts +0 -349
  84. package/src/singleton.ts +0 -187
  85. package/src/utils/index.ts +0 -132
  86. package/src/utils/sequencify.ts +0 -105
  87. package/src/utils/timing.ts +0 -128
package/src/egg.ts DELETED
@@ -1,617 +0,0 @@
1
- /* eslint-disable prefer-spread */
2
- import assert from 'node:assert';
3
- import { debuglog } from 'node:util';
4
-
5
- import {
6
- Application as KoaApplication,
7
- Context as KoaContext,
8
- Request as KoaRequest,
9
- Response as KoaResponse,
10
- type MiddlewareFunc as KoaMiddlewareFunc,
11
- type Next,
12
- } from '@eggjs/koa';
13
- import { EggConsoleLogger, type Logger } from 'egg-logger';
14
- import {
15
- EggRouter as Router,
16
- type RegisterOptions,
17
- type ResourcesController,
18
- } from '@eggjs/router';
19
- import type { ReadyFunctionArg } from 'get-ready';
20
-
21
- import { BaseContextClass } from './base_context_class.js';
22
- import { Timing } from './utils/timing.js';
23
- import { Lifecycle } from './lifecycle.js';
24
- import { EggLoader } from './loader/egg_loader.js';
25
- import utils, { type Fun } from './utils/index.js';
26
- import type { EggAppConfig } from './types.js';
27
- import {
28
- Singleton,
29
- type SingletonCreateMethod,
30
- type SingletonOptions,
31
- } from './singleton.js';
32
-
33
- const debug = debuglog('@eggjs/core/egg');
34
-
35
- export const EGG_LOADER = Symbol.for('egg#loader');
36
-
37
- export interface EggCoreOptions {
38
- baseDir: string;
39
- type: 'application' | 'agent';
40
- plugins?: any;
41
- serverScope?: string;
42
- env?: string;
43
- }
44
-
45
- export type EggCoreInitOptions = Partial<EggCoreOptions>;
46
-
47
- // export @eggjs/koa classes
48
- export { KoaRequest, KoaResponse, KoaContext, KoaApplication, Router };
49
-
50
- // export @eggjs/koa types
51
- export type { Next, KoaMiddlewareFunc };
52
-
53
- // export @eggjs/core classes
54
- export class Request extends KoaRequest {
55
- declare app: EggCore;
56
- declare response: Response;
57
- }
58
-
59
- export class Response extends KoaResponse {
60
- declare app: EggCore;
61
- declare request: Request;
62
- }
63
-
64
- export class Context extends KoaContext {
65
- declare app: EggCore;
66
- declare request: Request;
67
- declare response: Response;
68
- declare service: BaseContextClass;
69
-
70
- // #region router
71
-
72
- /**
73
- * Returns map of URL parameters for given `path` and `paramNames`.
74
- * @example
75
- * ##### ctx.params.id {string}
76
- *
77
- * `GET /api/users/1` => `'1'`
78
- *
79
- * ##### ctx.params.per_page {string}
80
- *
81
- * The number of every page, `GET /api/users?per_page=20` => `20`
82
- */
83
- params?: Record<string, string>;
84
- /**
85
- * Returns array of router regexp url path captures.
86
- */
87
- captures?: string[];
88
- /**
89
- * Returns the name of the matched router.
90
- */
91
- routerName?: string;
92
- /**
93
- * Returns the path of the matched router.
94
- */
95
- routerPath?: string | RegExp;
96
-
97
- // #endregion
98
- }
99
-
100
- // export @eggjs/core types
101
- export type MiddlewareFunc<T extends KoaContext = Context> =
102
- KoaMiddlewareFunc<T>;
103
-
104
- export class EggCore extends KoaApplication {
105
- options: EggCoreOptions;
106
- timing: Timing;
107
- console: EggConsoleLogger;
108
- BaseContextClass: typeof BaseContextClass;
109
- Controller: typeof BaseContextClass;
110
- Service: typeof BaseContextClass;
111
- Helper?: typeof BaseContextClass;
112
- lifecycle: Lifecycle;
113
- loader: EggLoader;
114
- #closePromise?: Promise<void>;
115
- #router?: Router;
116
-
117
- /** auto inject on loadService() */
118
-
119
- readonly serviceClasses: Record<string, any> = {};
120
- /** auto inject on loadController() */
121
-
122
- readonly controller: Record<string, any> = {};
123
- /** auto inject on loadMiddleware() */
124
- readonly middlewares: Record<
125
- string,
126
- (opt: unknown, app: EggCore) => MiddlewareFunc
127
- > = {};
128
-
129
- /**
130
- * @class
131
- * @param {Object} options - options
132
- * @param {String} [options.baseDir] - the directory of application
133
- * @param {String} [options.type] - whether it's running in app worker or agent worker
134
- * @param {Object} [options.plugins] - custom plugins
135
- * @since 1.0.0
136
- */
137
- constructor(options: EggCoreInitOptions = {}) {
138
- options.baseDir = options.baseDir ?? process.cwd();
139
- options.type = options.type ?? 'application';
140
- assert(
141
- typeof options.baseDir === 'string',
142
- 'options.baseDir required, and must be a string'
143
- );
144
- // assert(fs.existsSync(options.baseDir), `Directory ${options.baseDir} not exists`);
145
- // assert(fs.statSync(options.baseDir).isDirectory(), `Directory ${options.baseDir} is not a directory`);
146
- assert(
147
- options.type === 'application' || options.type === 'agent',
148
- 'options.type should be application or agent'
149
- );
150
- super();
151
-
152
- this.timing = new Timing();
153
- /**
154
- * @member {Object} EggCore#options
155
- * @private
156
- * @since 1.0.0
157
- */
158
- this.options = options as EggCoreOptions;
159
-
160
- /**
161
- * logging for EggCore, avoid using console directly
162
- * @member {Logger} EggCore#console
163
- * @private
164
- * @since 1.0.0
165
- */
166
- this.console = new EggConsoleLogger();
167
-
168
- /**
169
- * @member {BaseContextClass} EggCore#BaseContextClass
170
- * @since 1.0.0
171
- */
172
- this.BaseContextClass = BaseContextClass;
173
-
174
- /**
175
- * Base controller to be extended by controller in `app.controller`
176
- * @class Controller
177
- * @augments BaseContextClass
178
- * @example
179
- * class UserController extends app.Controller {}
180
- */
181
- const Controller = this.BaseContextClass;
182
-
183
- /**
184
- * Retrieve base controller
185
- * @member {Controller} EggCore#Controller
186
- * @since 1.0.0
187
- */
188
- this.Controller = Controller;
189
-
190
- /**
191
- * Base service to be extended by services in `app.service`
192
- * @class Service
193
- * @augments BaseContextClass
194
- * @example
195
- * class UserService extends app.Service {}
196
- */
197
- const Service = this.BaseContextClass;
198
-
199
- /**
200
- * Retrieve base service
201
- * @member {Service} EggCore#Service
202
- * @since 1.0.0
203
- */
204
- this.Service = Service;
205
-
206
- this.lifecycle = new Lifecycle({
207
- baseDir: options.baseDir,
208
- app: this,
209
- logger: this.console,
210
- });
211
- this.lifecycle.on('error', err => this.emit('error', err));
212
- this.lifecycle.on('ready_timeout', id => this.emit('ready_timeout', id));
213
- this.lifecycle.on('ready_stat', data => this.emit('ready_stat', data));
214
-
215
- /**
216
- * The loader instance, the default class is {@link EggLoader}.
217
- * If you want define
218
- * @member {EggLoader} EggCore#loader
219
- * @since 1.0.0
220
- */
221
- const Loader = this[EGG_LOADER];
222
- assert(Loader, "Symbol.for('egg#loader') is required");
223
- this.loader = new Loader({
224
- baseDir: options.baseDir,
225
- app: this,
226
- plugins: options.plugins,
227
- logger: this.console,
228
- serverScope: options.serverScope,
229
- env: options.env ?? '',
230
- EggCoreClass: EggCore,
231
- });
232
- }
233
-
234
- get logger(): Logger {
235
- return this.console;
236
- }
237
-
238
- get coreLogger(): Logger {
239
- return this.console;
240
- }
241
-
242
- /**
243
- * create a singleton instance
244
- * @param {String} name - unique name for singleton
245
- * @param {Function|AsyncFunction} create - method will be invoked when singleton instance create
246
- */
247
- addSingleton(name: string, create: SingletonCreateMethod) {
248
- const options: SingletonOptions = {
249
- name,
250
- create,
251
- app: this,
252
- };
253
- const singleton = new Singleton(options);
254
- const initPromise = singleton.init();
255
- if (initPromise) {
256
- this.lifecycle.registerBeforeStart(async () => {
257
- await initPromise;
258
- }, `${name}-singleton-init`);
259
- }
260
- }
261
-
262
- /**
263
- * override koa's app.use, support generator function
264
- * @since 1.0.0
265
- */
266
- use<T extends KoaContext = Context>(fn: MiddlewareFunc<T>) {
267
- assert(typeof fn === 'function', 'app.use() requires a function');
268
- debug('[use] add middleware: %o', fn._name || fn.name || '-');
269
- this.middleware.push(fn as unknown as KoaMiddlewareFunc);
270
- return this;
271
- }
272
-
273
- /**
274
- * Whether `application` or `agent`
275
- * @member {String}
276
- * @since 1.0.0
277
- */
278
- get type() {
279
- return this.options.type;
280
- }
281
-
282
- /**
283
- * The current directory of application
284
- * @member {String}
285
- * @see {@link AppInfo#baseDir}
286
- * @since 1.0.0
287
- */
288
- get baseDir() {
289
- return this.options.baseDir;
290
- }
291
-
292
- /**
293
- * Alias to {@link https://npmjs.com/package/depd}
294
- * @member {Function}
295
- * @since 1.0.0
296
- */
297
- get deprecate() {
298
- return utils.deprecated;
299
- }
300
-
301
- /**
302
- * The name of application
303
- * @member {String}
304
- * @see {@link AppInfo#name}
305
- * @since 1.0.0
306
- */
307
- get name() {
308
- return this.loader ? this.loader.pkg.name : '';
309
- }
310
-
311
- /**
312
- * Retrieve enabled plugins
313
- * @member {Object}
314
- * @since 1.0.0
315
- */
316
- get plugins() {
317
- return this.loader ? this.loader.plugins : {};
318
- }
319
-
320
- /**
321
- * The configuration of application
322
- * @member {Config}
323
- * @since 1.0.0
324
- */
325
- get config(): EggAppConfig {
326
- return this.loader ? this.loader.config : ({} as EggAppConfig);
327
- }
328
-
329
- /**
330
- * Execute scope after loaded and before app start.
331
- *
332
- * Notice:
333
- * This method is now NOT recommended and regarded as a deprecated one,
334
- * For plugin development, we should use `didLoad` instead.
335
- * For application development, we should use `willReady` instead.
336
- *
337
- * @see https://eggjs.org/en/advanced/loader.html#beforestart
338
- *
339
- * @param {Function} scope function will execute before app start
340
- * @param {string} [name] scope name, default is empty string
341
- */
342
- beforeStart(scope: Fun, name?: string) {
343
- this.deprecate(
344
- '`beforeStart` was deprecated, please use "Life Cycles" instead, see https://www.eggjs.org/advanced/loader#life-cycles'
345
- );
346
- this.lifecycle.registerBeforeStart(scope, name ?? '');
347
- }
348
-
349
- /**
350
- * register an callback function that will be invoked when application is ready.
351
- * @see https://github.com/node-modules/get-ready
352
- * @since 1.0.0
353
- * @example
354
- * const app = new Application(...);
355
- * app.ready(err => {
356
- * if (err) throw err;
357
- * console.log('done');
358
- * });
359
- */
360
- ready(): Promise<void>;
361
- ready(flagOrFunction: ReadyFunctionArg): void;
362
- ready(flagOrFunction?: ReadyFunctionArg) {
363
- if (flagOrFunction === undefined) {
364
- return this.lifecycle.ready();
365
- }
366
- return this.lifecycle.ready(flagOrFunction);
367
- }
368
-
369
- /**
370
- * If a client starts asynchronously, you can register `readyCallback`,
371
- * then the application will wait for the callback to ready
372
- *
373
- * It will log when the callback is not invoked after 10s
374
- *
375
- * Recommend to use {@link EggCore#beforeStart}
376
- * @since 1.0.0
377
- *
378
- * @param {String} name - readyCallback task name
379
- * @param {object} opts -
380
- * - {Number} [timeout=10000] - emit `ready_timeout` when it doesn't finish but reach the timeout
381
- * - {Boolean} [isWeakDep=false] - whether it's a weak dependency
382
- * @returns {Function} - a callback
383
- * @example
384
- * const done = app.readyCallback('mysql');
385
- * mysql.ready(done);
386
- */
387
- readyCallback(name: string, opts: object) {
388
- this.deprecate(
389
- '`readyCallback` was deprecated, please use "Life Cycles" instead, see https://www.eggjs.org/advanced/loader#life-cycles'
390
- );
391
- return this.lifecycle.legacyReadyCallback(name, opts);
392
- }
393
-
394
- /**
395
- * Register a function that will be called when app close.
396
- *
397
- * Notice:
398
- * This method is now NOT recommended directly used,
399
- * Developers SHOULDN'T use app.beforeClose directly now,
400
- * but in the form of class to implement beforeClose instead.
401
- *
402
- * @see https://eggjs.org/en/advanced/loader.html#beforeclose
403
- *
404
- * @param {Function} fn - the function that can be generator function or async function.
405
- */
406
- beforeClose(fn: Fun, name?: string) {
407
- this.deprecate(
408
- '`beforeClose` was deprecated, please use "Life Cycles" instead, see https://www.eggjs.org/advanced/loader#life-cycles'
409
- );
410
- this.lifecycle.registerBeforeClose(fn, name);
411
- }
412
-
413
- /**
414
- * Close all, it will close
415
- * - callbacks registered by beforeClose
416
- * - emit `close` event
417
- * - remove add listeners
418
- *
419
- * If error is thrown when it's closing, the promise will reject.
420
- * It will also reject after following call.
421
- * @returns {Promise} promise
422
- * @since 1.0.0
423
- */
424
- async close(): Promise<void> {
425
- if (this.#closePromise) return this.#closePromise;
426
- this.#closePromise = this.lifecycle.close();
427
- return this.#closePromise;
428
- }
429
-
430
- /**
431
- * get router
432
- * @member {Router} EggCore#router
433
- * @since 1.0.0
434
- */
435
- get router() {
436
- if (this.#router) {
437
- return this.#router;
438
- }
439
- this.#router = new Router({ sensitive: true }, this);
440
- return this.#router;
441
- }
442
-
443
- /**
444
- * Alias to {@link Router#url}
445
- * @param {String} name - Router name
446
- * @param {Object} params - more parameters
447
- * @returns {String} url
448
- */
449
- url(name: string, params?: Parameters<Router['url']>[1]): string {
450
- return this.router.url(name, params);
451
- }
452
-
453
- // delegate all router method to application
454
- // 'head', 'options', 'get', 'put', 'patch', 'post', 'delete'
455
- // 'all', 'resources', 'register', 'redirect'
456
- head(
457
- path: string | RegExp | (string | RegExp)[],
458
- ...middlewares: (MiddlewareFunc | string)[]
459
- ): EggCore;
460
- head(
461
- name: string,
462
- path: string | RegExp | (string | RegExp)[],
463
- ...middlewares: (MiddlewareFunc | string)[]
464
- ): EggCore;
465
-
466
- head(...args: any): EggCore {
467
- this.router.head.apply(this.router, args);
468
- return this;
469
- }
470
- // options(path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
471
- // options(name: string, path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
472
- // options(...args: any): EggCore {
473
- // this.router.options.apply(this.router, args);
474
- // return this;
475
- // }
476
- get(
477
- path: string | RegExp | (string | RegExp)[],
478
- ...middlewares: (MiddlewareFunc | string)[]
479
- ): EggCore;
480
- get(
481
- name: string,
482
- path: string | RegExp | (string | RegExp)[],
483
- ...middlewares: (MiddlewareFunc | string)[]
484
- ): EggCore;
485
-
486
- get(...args: any): EggCore {
487
- this.router.get.apply(this.router, args);
488
- return this;
489
- }
490
- put(
491
- path: string | RegExp | (string | RegExp)[],
492
- ...middlewares: (MiddlewareFunc | string)[]
493
- ): EggCore;
494
- put(
495
- name: string,
496
- path: string | RegExp | (string | RegExp)[],
497
- ...middlewares: (MiddlewareFunc | string)[]
498
- ): EggCore;
499
-
500
- put(...args: any): EggCore {
501
- this.router.put.apply(this.router, args);
502
- return this;
503
- }
504
- patch(
505
- path: string | RegExp | (string | RegExp)[],
506
- ...middlewares: (MiddlewareFunc | string)[]
507
- ): EggCore;
508
- patch(
509
- name: string,
510
- path: string | RegExp | (string | RegExp)[],
511
- ...middlewares: (MiddlewareFunc | string)[]
512
- ): EggCore;
513
-
514
- patch(...args: any): EggCore {
515
- this.router.patch.apply(this.router, args);
516
- return this;
517
- }
518
- post(
519
- path: string | RegExp | (string | RegExp)[],
520
- ...middlewares: (MiddlewareFunc | string)[]
521
- ): EggCore;
522
- post(
523
- name: string,
524
- path: string | RegExp | (string | RegExp)[],
525
- ...middlewares: (MiddlewareFunc | string)[]
526
- ): EggCore;
527
-
528
- post(...args: any): EggCore {
529
- this.router.post.apply(this.router, args);
530
- return this;
531
- }
532
- delete(
533
- path: string | RegExp | (string | RegExp)[],
534
- ...middlewares: (MiddlewareFunc | string)[]
535
- ): EggCore;
536
- delete(
537
- name: string,
538
- path: string | RegExp | (string | RegExp)[],
539
- ...middlewares: (MiddlewareFunc | string)[]
540
- ): EggCore;
541
-
542
- delete(...args: any): EggCore {
543
- this.router.delete.apply(this.router, args);
544
- return this;
545
- }
546
- del(
547
- path: string | RegExp | (string | RegExp)[],
548
- ...middlewares: (MiddlewareFunc | string)[]
549
- ): EggCore;
550
- del(
551
- name: string,
552
- path: string | RegExp | (string | RegExp)[],
553
- ...middlewares: (MiddlewareFunc | string)[]
554
- ): EggCore;
555
-
556
- del(...args: any): EggCore {
557
- this.router.del.apply(this.router, args);
558
- return this;
559
- }
560
-
561
- all(
562
- path: string | RegExp | (string | RegExp)[],
563
- ...middlewares: (MiddlewareFunc | string)[]
564
- ): EggCore;
565
- all(
566
- name: string,
567
- path: string | RegExp | (string | RegExp)[],
568
- ...middlewares: (MiddlewareFunc | string)[]
569
- ): EggCore;
570
-
571
- all(...args: any): EggCore {
572
- this.router.all.apply(this.router, args);
573
- return this;
574
- }
575
-
576
- resources(prefix: string, controller: string | ResourcesController): EggCore;
577
- resources(
578
- prefix: string,
579
- middleware: MiddlewareFunc,
580
- controller: string | ResourcesController
581
- ): EggCore;
582
- resources(
583
- name: string,
584
- prefix: string,
585
- controller: string | ResourcesController
586
- ): EggCore;
587
- resources(
588
- name: string,
589
- prefix: string,
590
- middleware: MiddlewareFunc,
591
- controller: string | ResourcesController
592
- ): EggCore;
593
-
594
- resources(...args: any): EggCore {
595
- this.router.resources.apply(this.router, args);
596
- return this;
597
- }
598
-
599
- redirect(source: string, destination: string, status = 301) {
600
- this.router.redirect(source, destination, status);
601
- return this;
602
- }
603
-
604
- register(
605
- path: string | RegExp | (string | RegExp)[],
606
- methods: string[],
607
- middleware: MiddlewareFunc | MiddlewareFunc[],
608
- opts?: RegisterOptions
609
- ) {
610
- this.router.register(path, methods, middleware, opts);
611
- return this;
612
- }
613
-
614
- get [EGG_LOADER]() {
615
- return EggLoader;
616
- }
617
- }
package/src/index.ts DELETED
@@ -1,14 +0,0 @@
1
- import utils from './utils/index.js';
2
-
3
- export { utils };
4
-
5
- export * from './egg.js';
6
- export * from './base_context_class.js';
7
- export * from './lifecycle.js';
8
- export * from './singleton.js';
9
- export * from './loader/egg_loader.js';
10
- export * from './loader/file_loader.js';
11
- export * from './loader/context_loader.js';
12
- export * from './utils/sequencify.js';
13
- export * from './utils/timing.js';
14
- export type * from './types.js';