feat(rest): adds msgpack body parser#6155
Conversation
eb11c4c to
ac3db6c
Compare
4f1862d to
ed552f6
Compare
|
Thank you @achrinza for the pull request! I'd like to discuss two aspects:
|
|
I like the idea of adding |
|
Thanks for the feedback @bajtos.
Thoughts? |
This package looks good too, although I am a bit worried that it's still in pre-1.0 version, the last version was published 4 years ago and their readme mentions Node.js 6 as the latest version being tested. I wish there was a single well-maintained package for dealing with msgpack in Node.js :( |
|
Let's see if twitter-verse can offer any wisdom: https://twitter.com/bajtos/status/1296454814587588674 |
I agree with @bajtos here and would recommend to keep this body parser as an extension. That would help to keep it separate and easier to maintain. BTW, I like the idea of having this parser. |
5c47ac8 to
0e9f000
Compare
bajtos
left a comment
There was a problem hiding this comment.
Thank you @achrinza for reworking the patch into a standalone extension 👏🏻
Now I don't mind much which msgpack implementation we use, because changing to a different library is going to affect only msgpack users, majority of LB4 users won't even notice 👍🏻
I have few comments on the implementation details, PTAL below 👇🏻
extensions/bodyparser-msgpack/src/__tests__/unit/bodyparser.unit.ts
Outdated
Show resolved
Hide resolved
|
Please check CI failures, for example https://travis-ci.com/github/strongloop/loopback-next/jobs/376022717#L298-L304: (I think this is related to #6155 (comment)). |
Travis Job (Click to expand)A bit stumped why Any suggestions? Edit: Fixed by #6175 |
bajtos
left a comment
There was a problem hiding this comment.
The new version looks mostly good, I have few more observations to discuss.
The CI build is still failing, PTAL.
124ca6d to
8b7145e
Compare
bajtos
left a comment
There was a problem hiding this comment.
You are making great progress!
| // | ||
| this._res | ||
| .type('application/msgpack') | ||
| .end(msgpack.encode(this.todoRepository.find(filter))); |
There was a problem hiding this comment.
Can you please update import statements in this example to show where is msgpack imported from?
I think it would be best if our users can use the same version of msgpack that's used for parsing the requests, i.e.
import {msgpack} from '@loopback/bodyparser-msgpack';There was a problem hiding this comment.
Also in the light of the discussion in https://github.com/strongloop/loopback-next/pull/6155/files#r481194436, maybe we should rename the extension to @loopback/rest-msgpack? (In the future, we may want to add msgpack support for other transports like messaging, so the rest- prefix should make it clear this extension is for REST.)
There was a problem hiding this comment.
maybe we should rename the extension to
@loopback/rest-msgpack
Just an idea to consider, maybe it's too early considering that this package will provide just the body parser for quite some time until we implement support for content-type negotiation in the framework.
There was a problem hiding this comment.
I think it makes sense to rename it to @loopback/rest-msgpack.
bodyparsers/msgpack/dist/__tests__/acceptance/bodyparser.acceptance.d.ts
Outdated
Show resolved
Hide resolved
1c1be37 to
6faf732
Compare
nitpick: we use imperative tense in commit messages, i.e. |
bajtos
left a comment
There was a problem hiding this comment.
Almost there! I have few minor comments to consider, PTAL below.
Please wait few more days before landing, to get @raymondfeng a chance to review the final version too.
| layout: readme | ||
| source: loopback-next | ||
| file: bodyparsers/msgpack/README.md | ||
| permalink: /doc/en/lb4/Using-messagepack-with-loopback.html |
There was a problem hiding this comment.
AFAICT, this page is not referenced from the sidebar, can we remove it?
As of loopbackio/loopback.io#996, we allow sidebar entries (group headings) with no linked page.
There was a problem hiding this comment.
It's being referenced here: https://github.com/strongloop/loopback-next/pull/6155/files#diff-967acfe8350a9043a788970b5cf91223R236
docs/site/sidebars/lb4_sidebar.yml
Outdated
| - title: 'Using MessagePack' | ||
| output: 'web, pdf' | ||
| children: | ||
| - title: 'How to use MessagePack with LoopBack' |
There was a problem hiding this comment.
Are you expecting to have multiple pages under Using MessagePack section? To me, this feels like an extra nesting.
There was a problem hiding this comment.
Good point, I've removed the nesting.
It was initially taken from the TypeORM extension
6faf732 to
0503592
Compare
Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com>
0503592 to
9906078
Compare
Signed-off-by: Rifa Achrinza 25147899+achrinza@users.noreply.github.com
Checklist
npm testpasses on your machinepackages/cliwere updatedexamples/*were updated👉 Check out how to submit a PR 👈