Skip to content

Commit

Permalink
fix: export handleRequest on application (#10)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
fengmk2 authored Jul 7, 2024
1 parent 5db7a9e commit dfda217
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
"eslint-config-egg/typescript"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ lib
!lib/application.test-d.ts
package-lock.json
.tshy*
.eslintcache
65 changes: 64 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,52 +1,72 @@
小菜 <[email protected]>
Aaron Heckmann <[email protected]>
Adam L <[email protected]>
Adam Lau <[email protected]>
Aesop Wolf <[email protected]>
AlbertAZ1992 <[email protected]>
Alex Berk <[email protected]>
AlexeyKhristov <[email protected]>
Alexsey <[email protected]>
Amit Portnoy <[email protected]>
Andrew Peterson <[email protected]>
André Cruz <[email protected]>
Anton Harniakou <[email protected]>
Arjun <[email protected]>
Asiel Leal <[email protected]>
Avindra Goolcharan <[email protected]>
Bartol Karuza <[email protected]>
Ben Reinhart <[email protected]>
Bernie Stern <[email protected]>
Brad Ito <[email protected]>
Bryan Bess <[email protected]>
C.T. Lin <[email protected]>
Chiahao Lin <[email protected]>
Chris Tarquini <[email protected]>
Christian Rodemeyer <[email protected]>
Christoffer Hallas <[email protected]>
Clark Du <[email protected]>
Clayton Ray <[email protected]>
Darren Cauthon <[email protected]>
Debjeet Biswas <[email protected]>
Dmitry Mazuro <[email protected]>
Dobes Vandermeer <[email protected]>
Douglas Christopher Wilson <[email protected]>
Douglas Wade <[email protected]>
Edvard Chen <[email protected]>
Eivind Fjeldstad <[email protected]>
Equim <[email protected]>
Fangdun Cai <[email protected]>
Felix Becker <[email protected]>
Filip Skokan <[email protected]>
Francisco Presencia <[email protected]>
Francisco Ryan Tolmasky I <[email protected]>
George Chung <[email protected]>
Gilles De Mey <[email protected]>
Grand <[email protected]>
Guilherme Pacheco <[email protected]>
Gunnlaugur Thor Briem <[email protected]>
Gxkl <[email protected]>
HanHor Wu <[email protected]>
Hartley Melamed <[email protected]>
Hridayesh Sharma <[email protected]>
Hrvoje Šimić <[email protected]>
Hugh Kennedy <[email protected]>
Ian Storm Taylor <[email protected]>
Igor Adamenko <[email protected]>
Ikko Ashimine <[email protected]>
Ilkka Oksanen <[email protected]>
Imed Jaberi <[email protected]>
Imon-Haque <[email protected]>
Ivan Kleshnin <[email protected]>
Ivan Lyons <[email protected]>
Jacob Bass <[email protected]>
Jake <[email protected]>
James George <[email protected]>
JamesWang <[email protected]>
Jan Buschtöns <[email protected]>
Jan Carlo Viray <[email protected]>
Jason Macgowan <[email protected]>
Jed Schmidt <[email protected]>
Jeff <[email protected]>
Jeff Moore <[email protected]>
Jesus Rodriguez <[email protected]>
Jesús Rodríguez Rodríguez <[email protected]>
Expand All @@ -55,47 +75,65 @@ Johan Bergström <[email protected]>
Jonas Zhang <[email protected]>
Jonathan Ong <[email protected]>
Jonathan Ong <[email protected]>
Jordan <[email protected]>
Joseph Lin <[email protected]>
Julian Gruber <[email protected]>
Julien Wajsberg <[email protected]>
Kareem Kwong <[email protected]>
Karl Böhlmark <[email protected]>
Kenneth Ormandy <[email protected]>
Kim Joar Bekkelund <[email protected]>
Konstantin Vyatkin <[email protected]>
Kwyn Alice Meagher <[email protected]>
Kyle Suss <[email protected]>
Lee Bousfield <[email protected]>
Louis DeScioli <[email protected]>
Luke Bousfield <[email protected]>
Malcolm <[email protected]>
Marc-Aurèle DARCHE <[email protected]>
Marceli.no <[email protected]>
Mars Wong <[email protected]>
Martin Iwanowski <[email protected]>
Martin Iwanowski <[email protected]>
Martin Michaelis <[email protected]>
Martin fl0w Iwanowski <[email protected]>
Matan Shavit <[email protected]>
Matheus Azzi <[email protected]>
Matheus Souza <[email protected]>
Mathieu Gallé-Tessonneau <[email protected]>
Matt Kubej <[email protected]>
Matthew Chase Whittemore <[email protected]>
Matthew King <[email protected]>
Matthew Mueller <[email protected]>
Mengdi Gao <[email protected]>
Michaël Zasso <[email protected]>
Michał Gołębiowski <[email protected]>
Michał Gołębiowski-Owczarek <[email protected]>
Micheal Hill <[email protected]>
Mike Vosseller <[email protected]>
Mikhail Bodrov <[email protected]>
Nathan Rajlich <[email protected]>
New Now Nohow <[email protected]>
Nick McCurdy <[email protected]>
Nicolae Vartolomei <[email protected]>
Olle Jonsson <[email protected]>
PatrickJS <[email protected]>
Paul Anderson <[email protected]>
Paul Annekov <[email protected]>
Pedro Pablo Aste Kompen <[email protected]>
Peeyush Kushwaha <[email protected]>
Peng Jie <[email protected]>
Peng Jie <[email protected]>
Phillip Alexander <[email protected]>
Piotr Kuczynski <[email protected]>
PlasmaPower <[email protected]>
Prayag Verma <[email protected]>
Qiming zhao <[email protected]>
Remek Ambroziak <[email protected]>
Riceball LEE <[email protected]>
Richard Marmorstein <[email protected]>
Rico Sta. Cruz <[email protected]>
Robert Nagy <[email protected]>
Robert Sköld <[email protected]>
Robin Pokorný <[email protected]>
Ruben Bridgewater <[email protected]>
Expand Down Expand Up @@ -124,53 +162,78 @@ Todor Stoychev <[email protected]>
Tomas Ruud <[email protected]>
Travis Jeffery <[email protected]>
Usman Hussain <[email protected]>
Vern Brandl <[email protected]>
Veselin Todorov <[email protected]>
Vijay Krishnavanshi <[email protected]>
Vikram Rangaraj <[email protected]>
Waleed Ashraf <[email protected]>
Wang Dàpéng <[email protected]>
Xavier Damman <[email protected]>
Xiang Gao <[email protected]>
Yanick Rochon <[email protected]>
Yazan Medanat <[email protected]>
Yazhong Liu <[email protected]>
Yazhong Liu <[email protected]>
Yiyu He <[email protected]>
Yiyu He <[email protected]>
Yoshua Wuyts <[email protected]>
Yu Qi <[email protected]>
Yu Qi <[email protected]>
ZYSzys <[email protected]>
ZYSzys <[email protected]>
Zac Anger <[email protected]>
Zack Tanner <[email protected]>
alsotang <[email protected]>
bananaappletw <[email protected]>
bhanuc <[email protected]>
blaz <[email protected]>
broucz <[email protected]>
call me saisai <[email protected]>
d3v <[email protected]>
dead-horse <[email protected]>
dead_horse <[email protected]>
designgrill <[email protected]>
ejose19 <[email protected]>
fengmk2 <[email protected]>
fengmk2 <[email protected]>
fengmk2 <[email protected]>
frank <[email protected]>
fundon <[email protected]>
gyson <[email protected]>
haoxin <[email protected]>
haoxin <[email protected]>
hyj1991 <[email protected]>
iamchenxin <[email protected]>
imed jaberi <[email protected]>
initial-wu <[email protected]>
jeremiG <[email protected]>
jeromew <[email protected]>
joehecn <[email protected]>
jongleberry <[email protected]>
jongleberry <[email protected]>
jongleberry <[email protected]>
kzhang <[email protected]>
laffachan <[email protected]>
llambda <[email protected]>
mako-taco <[email protected]>
mdemo <[email protected]>
miwnwski <[email protected]>
nicoder <[email protected]>
niftylettuce <[email protected]>
nswbmw <[email protected]>
pana <[email protected]>
qingming <[email protected]>
rosald <[email protected]>
semantic-release-bot <[email protected]>
song <[email protected]>
superchink <[email protected]>
tmilewski <[email protected]>
urugator <[email protected]>
yoshuawuyts <[email protected]>
yosssi <[email protected]>
zensh <[email protected]>
ziyunfei <[email protected]>
小雷 <[email protected]>
小菜 <[email protected]>
谭九鼎 <[email protected]>
石发磊 <[email protected]>
10 changes: 6 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]) to disclose.

## Authors

See [AUTHORS](AUTHORS).

## Community

- [Examples](https://github.com/koajs/examples)
Expand All @@ -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).
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
}
4 changes: 2 additions & 2 deletions src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
};

Expand All @@ -186,7 +186,7 @@ export class Application extends Emitter {
* Handle request in callback.
* @private
*/
async #handleRequest(ctx: ContextDelegation, fnMiddleware: (ctx: ContextDelegation) => Promise<void>) {
protected async handleRequest(ctx: ContextDelegation, fnMiddleware: (ctx: ContextDelegation) => Promise<void>) {
const res = ctx.res;
res.statusCode = 404;
const onerror = (err: any) => ctx.onerror(err);
Expand Down

0 comments on commit dfda217

Please sign in to comment.