From dfda217c51c00d7b0bcbefc281104c6be45ffebb Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 7 Jul 2024 22:35:39 +0800 Subject: [PATCH] fix: export handleRequest on application (#10) ## Summary by CodeRabbit - **Documentation** - Updated the README to replace the `Authors` section with a `Contributors` section, including a link to contributors' images. - **Refactor** - Changed the `handleRequest` method in the `Application` class from private to protected to improve method accessibility for extended classes. - **Chores** - Simplified `.eslintrc` configuration by removing a specific rule enforcement. --- .eslintrc | 3 +-- .gitignore | 1 + AUTHORS | 65 +++++++++++++++++++++++++++++++++++++++++++++- Readme.md | 10 ++++--- package.json | 5 ++-- src/application.ts | 4 +-- 6 files changed, 77 insertions(+), 11 deletions(-) diff --git a/.eslintrc b/.eslintrc index 9bcdb4688..98f9236ae 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,6 +1,5 @@ { "extends": [ - "eslint-config-egg/typescript", - "eslint-config-egg/lib/rules/enforce-node-prefix" + "eslint-config-egg/typescript" ] } diff --git a/.gitignore b/.gitignore index f1f15ec30..4ad44656b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ lib !lib/application.test-d.ts package-lock.json .tshy* +.eslintcache diff --git a/AUTHORS b/AUTHORS index d2d048818..ed02a2989 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,11 +1,14 @@ -小菜 Aaron Heckmann Adam L Adam Lau Aesop Wolf +AlbertAZ1992 +Alex Berk AlexeyKhristov Alexsey Amit Portnoy +Andrew Peterson +André Cruz Anton Harniakou Arjun Asiel Leal @@ -13,40 +16,57 @@ Avindra Goolcharan Bartol Karuza Ben Reinhart Bernie Stern +Brad Ito Bryan Bess C.T. Lin Chiahao Lin Chris Tarquini +Christian Rodemeyer Christoffer Hallas Clark Du +Clayton Ray Darren Cauthon Debjeet Biswas Dmitry Mazuro +Dobes Vandermeer Douglas Christopher Wilson +Douglas Wade +Edvard Chen Eivind Fjeldstad Equim Fangdun Cai Felix Becker Filip Skokan Francisco Presencia +Francisco Ryan Tolmasky I George Chung Gilles De Mey Grand Guilherme Pacheco +Gunnlaugur Thor Briem +Gxkl HanHor Wu Hartley Melamed +Hridayesh Sharma Hrvoje Šimić Hugh Kennedy Ian Storm Taylor +Igor Adamenko +Ikko Ashimine Ilkka Oksanen +Imed Jaberi +Imon-Haque <38266345+Imon-Haque@users.noreply.github.com> Ivan Kleshnin Ivan Lyons Jacob Bass +Jake +James George JamesWang Jan Buschtöns Jan Carlo Viray Jason Macgowan Jed Schmidt +Jeff Jeff Moore Jesus Rodriguez Jesús Rodríguez Rodríguez @@ -55,40 +75,57 @@ Johan Bergström Jonas Zhang <106856363@qq.com> Jonathan Ong Jonathan Ong +Jordan Joseph Lin Julian Gruber +Julien Wajsberg Kareem Kwong Karl Böhlmark Kenneth Ormandy Kim Joar Bekkelund +Konstantin Vyatkin Kwyn Alice Meagher Kyle Suss Lee Bousfield Louis DeScioli Luke Bousfield Malcolm +Marc-Aurèle DARCHE <152407+madarche@users.noreply.github.com> Marceli.no Mars Wong Martin Iwanowski Martin Iwanowski +Martin Michaelis Martin fl0w Iwanowski +Matan Shavit <71092861+matanshavit@users.noreply.github.com> Matheus Azzi +Matheus Souza <37983247+souzasmatheus@users.noreply.github.com> Mathieu Gallé-Tessonneau +Matt Kubej Matthew Chase Whittemore Matthew King Matthew Mueller Mengdi Gao Michaël Zasso +Michał Gołębiowski Michał Gołębiowski-Owczarek +Micheal Hill +Mike Vosseller +Mikhail Bodrov Nathan Rajlich New Now Nohow Nick McCurdy Nicolae Vartolomei +Olle Jonsson PatrickJS Paul Anderson +Paul Annekov Pedro Pablo Aste Kompen Peeyush Kushwaha +Peng Jie +Peng Jie Phillip Alexander +Piotr Kuczynski PlasmaPower Prayag Verma Qiming zhao @@ -96,6 +133,7 @@ Remek Ambroziak Riceball LEE Richard Marmorstein Rico Sta. Cruz +Robert Nagy Robert Sköld Robin Pokorný Ruben Bridgewater @@ -124,11 +162,16 @@ Todor Stoychev Tomas Ruud Travis Jeffery Usman Hussain +Vern Brandl Veselin Todorov +Vijay Krishnavanshi +Vikram Rangaraj +Waleed Ashraf Wang Dàpéng Xavier Damman Xiang Gao Yanick Rochon +Yazan Medanat Yazhong Liu Yazhong Liu Yiyu He @@ -136,41 +179,61 @@ Yiyu He Yoshua Wuyts Yu Qi Yu Qi +ZYSzys +ZYSzys +Zac Anger Zack Tanner alsotang bananaappletw bhanuc blaz broucz +call me saisai <1457358080@qq.com> d3v dead-horse dead_horse designgrill +ejose19 <8742215+ejose19@users.noreply.github.com> fengmk2 fengmk2 +fengmk2 frank fundon gyson haoxin haoxin +hyj1991 iamchenxin +imed jaberi initial-wu +jeremiG jeromew joehecn jongleberry +jongleberry jongleberry +kzhang +laffachan <45162759+laffachan@users.noreply.github.com> llambda mako-taco mdemo +miwnwski nicoder +niftylettuce nswbmw pana qingming <358242939@qq.com> +rosald <35028438+rosald@users.noreply.github.com> +semantic-release-bot song superchink tmilewski +urugator yoshuawuyts yosssi zensh ziyunfei <446240525@qq.com> +小雷 <863837949@qq.com> +小菜 +谭九鼎 <109224573@qq.com> 石发磊 diff --git a/Readme.md b/Readme.md index 08e3d568a..a91b74bef 100644 --- a/Readme.md +++ b/Readme.md @@ -170,10 +170,6 @@ npm test To report a security vulnerability, please do not open an issue, as this notifies attackers of the vulnerability. Instead, please email [fengmk2](mailto:fengmk2+eggjs@gmail.com) to disclose. -## Authors - -See [AUTHORS](AUTHORS). - ## Community - [Examples](https://github.com/koajs/examples) @@ -184,3 +180,9 @@ See [AUTHORS](AUTHORS). ## License [MIT](LICENSE) + +## Contributors + +[![Contributors](https://contrib.rocks/image?repo=eggjs/koa)](https://github.com/eggjs/koa/graphs/contributors) + +Made with [contributors-img](https://contrib.rocks). diff --git a/package.json b/package.json index 09342e666..73834f138 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "test": "npm run lint -- --fix && egg-bin test", "ci": "npm run lint && egg-bin cov && npm run prepublishOnly && attw --pack", - "lint": "eslint src test", + "lint": "eslint src test --cache", "authors": "git log --format='%aN <%aE>' | sort -u > AUTHORS", "prepublishOnly": "tshy && tshy-after" }, @@ -107,5 +107,6 @@ "src" ], "main": "./dist/commonjs/index.js", - "types": "./dist/commonjs/index.d.ts" + "types": "./dist/commonjs/index.d.ts", + "module": "./dist/esm/index.js" } diff --git a/src/application.ts b/src/application.ts index ce4cfcd7e..aca15b935 100644 --- a/src/application.ts +++ b/src/application.ts @@ -168,7 +168,7 @@ export class Application extends Emitter { const handleRequest = (req: IncomingMessage, res: ServerResponse) => { const ctx = this.createContext(req, res); return this.ctxStorage.run(ctx, async () => { - return await this.#handleRequest(ctx, fn); + return await this.handleRequest(ctx, fn); }); }; @@ -186,7 +186,7 @@ export class Application extends Emitter { * Handle request in callback. * @private */ - async #handleRequest(ctx: ContextDelegation, fnMiddleware: (ctx: ContextDelegation) => Promise) { + protected async handleRequest(ctx: ContextDelegation, fnMiddleware: (ctx: ContextDelegation) => Promise) { const res = ctx.res; res.statusCode = 404; const onerror = (err: any) => ctx.onerror(err);