-
Notifications
You must be signed in to change notification settings - Fork 26.3k
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
Added generic type for body in NextApiRequest #15139
Conversation
Stats from current PRDefault Server ModeGeneral Overall increase
|
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
buildDuration | 12s | 11.5s | -486ms |
nodeModulesSize | 66.5 MB | 66.5 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.065 | 2.03 | -0.04 |
/ avg req/sec | 1210.49 | 1231.3 | +20.81 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.311 | 1.323 | |
/error-in-render avg req/sec | 1907.44 | 1889.77 |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
main-HASH.js gzip | 6.72 kB | 6.72 kB | ✓ |
webpack-HASH.js gzip | 751 B | 751 B | ✓ |
19b7e98f51cc..cead.js gzip | 9.77 kB | 9.77 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 56.4 kB | 56.4 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.79 kB | 5.79 kB | ✓ |
webpack-HASH..dule.js gzip | 751 B | 751 B | ✓ |
19b7e98f51cc..dule.js gzip | 6.17 kB | 6.17 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 51.9 kB | 51.9 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.4 kB | 26.4 kB | ✓ |
Overall change | 26.4 kB | 26.4 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
_buildManifest.js gzip | 267 B | 267 B | ✓ |
_buildManife..dule.js gzip | 273 B | 273 B | ✓ |
Overall change | 540 B | 540 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
index.html gzip | 955 B | 955 B | ✓ |
link.html gzip | 962 B | 962 B | ✓ |
withRouter.html gzip | 947 B | 947 B | ✓ |
Overall change | 2.86 kB | 2.86 kB | ✓ |
Serverless Mode
General Overall increase ⚠️
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
buildDuration | 12.7s | 12.7s | -41ms |
nodeModulesSize | 66.5 MB | 66.5 MB |
Client Bundles (main, webpack, commons)
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
main-HASH.js gzip | 6.72 kB | 6.72 kB | ✓ |
webpack-HASH.js gzip | 751 B | 751 B | ✓ |
19b7e98f51cc..cead.js gzip | 9.77 kB | 9.77 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 56.4 kB | 56.4 kB | ✓ |
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
main-HASH.module.js gzip | 5.79 kB | 5.79 kB | ✓ |
webpack-HASH..dule.js gzip | 751 B | 751 B | ✓ |
19b7e98f51cc..dule.js gzip | 6.17 kB | 6.17 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 51.9 kB | 51.9 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 26.4 kB | 26.4 kB | ✓ |
Overall change | 26.4 kB | 26.4 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
_buildManifest.js gzip | 267 B | 267 B | ✓ |
_buildManife..dule.js gzip | 273 B | 273 B | ✓ |
Overall change | 540 B | 540 B | ✓ |
Serverless bundles
vercel/next.js canary | Nirzhuk/next.js next_api_request_generic_type_body | Change | |
---|---|---|---|
_error.js | 881 kB | 881 kB | ✓ |
404.html | 4.17 kB | 4.17 kB | ✓ |
hooks.html | 3.79 kB | 3.79 kB | ✓ |
index.js | 881 kB | 881 kB | ✓ |
link.js | 923 kB | 923 kB | ✓ |
routerDirect.js | 917 kB | 917 kB | ✓ |
withRouter.js | 917 kB | 917 kB | ✓ |
Overall change | 4.53 MB | 4.53 MB | ✓ |
Hi there @Nirzhuk thank you for the PR, I'm going to close the PR as this change is not required for the following reason:
For example: function validate(body: any) {
// ...
return body as MyType
}
// ...
const body = validate(req.body) In the above example your code will properly set the type, and only after validating that such type is correct. |
@lfades Thanks for answering. |
Generic Type for the body in NextApiRequests to implement your custom interfaces to handle better the data.