+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"dependencies": {
"@eggjs/koa": "^2.20.6",
"@eggjs/router": "^3.0.5",
"@eggjs/utils": "^4.2.4",
"@eggjs/utils": "^4.3.0",
"egg-logger": "^3.5.0",
"egg-path-matching": "^2.0.0",
"extend2": "^4.0.0",
Expand Down
29 changes: 29 additions & 0 deletions src/egg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,35 @@
declare request: Request;
declare response: Response;
declare service: BaseContextClass;

// #region router

/**
* Returns map of URL parameters for given `path` and `paramNames`.
* @example
* ##### ctx.params.id {string}
*
* `GET /api/users/1` => `'1'`
*
* ##### ctx.params.per_page {string}
*
* The number of every page, `GET /api/users?per_page=20` => `20`
*/
params?: Record<string, string>;
/**
* Returns array of router regexp url path captures.
*/
captures?: string[];
/**
* Returns the name of the matched router.
*/
routerName?: string;
/**
* Returns the path of the matched router.
*/

Check warning on line 92 in src/egg.ts

View check run for this annotation

Codecov / codecov/patch

src/egg.ts#L82-L92

Added lines #L82 - L92 were not covered by tests
routerPath?: string | RegExp;

// #endregion
}

// export @eggjs/core types
Expand Down
3 changes: 2 additions & 1 deletion src/loader/file_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { debuglog } from 'node:util';
import path from 'node:path';
import globby from 'globby';
import { isClass, isGeneratorFunction, isAsyncFunction, isPrimitive } from 'is-type-of';
import { isSupportTypeScript } from '@eggjs/utils';
import utils, { Fun } from '../utils/index.js';

const debug = debuglog('@eggjs/core/file_loader');
Expand Down Expand Up @@ -162,7 +163,7 @@ export class FileLoader {
protected async parse(): Promise<FileLoaderParseItem[]> {
let files = this.options.match;
if (!files) {
files = (process.env.EGG_TYPESCRIPT === 'true' && utils.extensions['.ts'])
files = isSupportTypeScript()
? [ '**/*.(js|ts)', '!**/*.d.ts' ]
: [ '**/*.js' ];
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/egg-ts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('test/egg-ts.test.ts', () => {
assert(!app.serviceClasses.test);
});

it('should not load ts files while EGG_TYPESCRIPT was true but no extensions', async () => {
it.skip('should not load ts files while EGG_TYPESCRIPT was true but no extensions', async () => {
mm(process.env, 'EGG_TYPESCRIPT', 'true');
mm(utils, 'extensions', [ '.js', '.json' ]);
app = createApp('egg-ts-js');
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载