-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add support for App Router #49
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
blomqma
force-pushed
the
upgrade-dependencies
branch
2 times, most recently
from
August 24, 2023 19:22
aff605d
to
35e85ef
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
August 24, 2023 19:37
35e85ef
to
7621a2b
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 11, 2023 21:52
a261c09
to
1579a23
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 11, 2023 21:58
1579a23
to
eba06e1
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 11, 2023 22:05
eba06e1
to
2b33d77
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 12, 2023 21:57
c0a3691
to
4dbfa07
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 12, 2023 22:01
4dbfa07
to
58401ea
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 12, 2023 22:04
58401ea
to
de76816
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 12, 2023 22:06
de76816
to
33d53aa
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 12, 2023 23:30
2b17f86
to
1fe5559
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 12, 2023 23:35
1fe5559
to
2a2d096
Compare
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 12, 2023 23:39
2a2d096
to
236141e
Compare
This is a breaking change that adds support for using Next REST Framework with the Next.js App Router. The support for Pages Router is also supported, and even both routers can be used simultaneously with the framework, like done in the revamped example application. There are a few fundamental changes in both the implementation of the code and in how the framework is encouraged to be used: Remove support for middlewares: Next.js has it's own way of implementing middleware logic for server-side code. By removing the optional logic for global, route and method middlewares we ensure that any user-defined logic in these handler's won't interfere or encourage developers to implement their preferred logic in a non-Next.js way. Supporting different runtimes, like the Node.js environment and the edge runtime are also not possible, making it wiser to leave any additional middleware logic up to the user to implement either directly in their route handlers, or in their global Next.js middleware logic. Leaving our the three-level middleware logic also simplifies the typings, that are already very strict. With these changes, the user can still define an optional global error handler for catching any errors occurring in their Next REST Framework route handlers, but defining overriding error handlers on route or method level is no longer supported. Remove support for HTTP TRACE: The Next.js App Router adds it's own validation for the HTTP methods being used, and TRACE is not supported by that. With these changes, TRACE can no longer be used with neither App Router or Pages Router with Next REST Framework. Not encouraging running the generation script with `next build`: The `next-rest-framework` binary still works in a similar way, generating the `openapi.json` file in the root of the project. Running the script that spawns a child process running a Next.js dev server is longer encouraged to be done with `next build`, as performing this in build environments can have varying success or it may not work at all. Instead, it is recommended to still keep the `openapi.json` file under source control and instead, run the generation script as part of pre-commit hooks or before committing changes that modify the OpenAPI spec. The `openapi.json` file is still automatically updated during local development, making this manual step redundant in most cases. Removing support for Node.js 16: As Node.js 16 is facing EOL, and the Next.js App Router is not supported with Node.js 16, that Node version is longer supported. Node 20 can be considered to be added to the CI machine matrix, but as Vercel does not currently support Node 20, that has not yet been done here. Additionally, this change upgrades most dependencies to latest versions.
blomqma
force-pushed
the
upgrade-dependencies
branch
from
September 12, 2023 23:53
236141e
to
961745d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for App Router
This is a breaking change that adds support for
using Next REST Framework with the Next.js App Router.
The support for Pages Router is also supported, and even
both routers can be used simultaneously with the framework,
like done in the revamped example application.
There are a few fundamental changes in both the implementation
of the code and in how the framework is encouraged to be used:
Remove support for middlewares:
Next.js has it's own way of implementing middleware logic
for server-side code. By removing the optional logic for
global, route and method middlewares we ensure that any
user-defined logic in these handler's won't interfere or
encourage developers to implement their preferred logic in
a non-Next.js way.
Supporting different runtimes, like the Node.js environment and
the edge runtime are also not possible, making it wiser to leave
any additional middleware logic up to the user to implement either
directly in their route handlers, or in their global Next.js
middleware logic.
Leaving our the three-level middleware logic also simplifies the
typings, that are already very strict.
With these changes, the user can still define an optional global
error handler for catching any errors occurring in their Next REST
Framework route handlers, but defining overriding error handlers on
route or method level is no longer supported.
Remove support for HTTP TRACE:
The Next.js App Router adds it's own validation for the HTTP methods
being used, and TRACE is not supported by that. With these changes,
TRACE can no longer be used with neither App Router or Pages Router
with Next REST Framework.
Not encouraging running the generation script with
next build
:The
next-rest-framework
binary still works in a similar way,generating the
openapi.json
file in the root of the project.Running the script that spawns a child process running a Next.js
dev server is longer encouraged to be done with
next build
,as performing this in build environments can have varying success
or it may not work at all. Instead, it is recommended to still keep
the
openapi.json
file under source control and instead, run thegeneration script as part of pre-commit hooks or before committing
changes that modify the OpenAPI spec. The
openapi.json
fileis still automatically updated during local development, making
this manual step redundant in most cases.
Removing support for Node.js 16:
As Node.js 16 is facing EOL, and the Next.js App Router is not
supported with Node.js 16, that Node version is longer supported.
Node 20 can be considered to be added to the CI machine matrix, but
as Vercel does not currently support Node 20, that has not yet been
done here.
Additionally, this change upgrades most dependencies to latest versions.