-
Notifications
You must be signed in to change notification settings - Fork 5
feat(request): Improve hono request output #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
fix test Signed-off-by: ysknsid25 <kengo071225@gmail.com>
fix function name `parsedResponseBody` Signed-off-by: ysknsid25 <kengo071225@gmail.com>
fix README Signed-off-by: ysknsid25 <kengo071225@gmail.com>
fix output format when direct`exclude` Signed-off-by: ysknsid25 <kengo071225@gmail.com>
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
commit: |
|
Hey @ysknsid25 If it's ready to review, please ping me! |
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
resolve [object Object] when console.log to terminal Signed-off-by: ysknsid25 <kengo071225@gmail.com>
|
@yusukebe |
src/utils/file.ts
Outdated
| import { existsSync, createWriteStream } from 'node:fs' | ||
| import { dirname, basename } from 'node:path' | ||
|
|
||
| export const getFilenameFromPath = (path: string): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the current implementation, if the path is /, the file name will be blank, and an error will occur.
Error saving file: ENOENT: no such file or directory, open ''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried setting a default filename. When request to / and direct --remote-name, / is named index.
What do you think?👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, adding an extension that depends on the content type is best. For example, if the content is application/json, the name will be index.json.
Plus, it's not just about this issue; should we also check whether the same file name exists in the current directory and avoid overwriting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For json, html, xml, and txt, which are likely to be responses for /, we have tried to add extensions based on the contentType 👀
We have also implemented overwrite prevention.
|
@ysknsid25 Thank you! I left some comments. Hey @usualoma Can you also review this, if you have time! |
usualoma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the great work!
I've added one comment.
fix return to continue Signed-off-by: ysknsid25 <kengo071225@gmail.com>
To be able to handle `application/json; charset=utf-8` Signed-off-by: ysknsid25 <kengo071225@gmail.com>
show more rich http header Signed-off-by: ysknsid25 <kengo071225@gmail.com>
fix `formatResponseBody()` return type. string to string | object Signed-off-by: ysknsid25 <kengo071225@gmail.com>
To be able to save when request to / Signed-off-by: ysknsid25 <kengo071225@gmail.com>
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
usualoma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
fix indexOf to regular expressions Signed-off-by: ysknsid25 <kengo071225@gmail.com>
For some contentTypes, set the extension Signed-off-by: ysknsid25 <kengo071225@gmail.com>
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
For some contentTypes, set the extension by using `hono/utils/mime` Signed-off-by: ysknsid25 <kengo071225@gmail.com>
yusukebe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
Looks good! Let's land it. Thank you for your great work! |
resolves: #51
-o <path>and-O-Jand--json-iand-ISample
app.tsuse this png image
Default(Pretty Format)
node ./dist/cli.js request ./src/app.tsBinary Response & not save
node ./dist/cli.js request ./src/app.ts -P /image.pngJSON Response &
-o <path>node ./dist/cli.js request ./src/app.ts -o index.jsonJSON Response &
-Onode ./dist/cli.js request ./src/app.ts -P /text -OBinary Response &
-o <path>node ./dist/cli.js request ./src/app.ts -P /image.png -o test.pngBinary Response &
-Onode ./dist/cli.js request ./src/app.ts -P /image.png -O-Jand--jsonnode ./dist/cli.js request ./src/app.ts -J-Inode ./dist/cli.js request ./src/app.ts -I-inode ./dist/cli.js request ./src/app.ts -J -i