-
Notifications
You must be signed in to change notification settings - Fork 19
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
Improved exported paths, added NextAppRouter specific platform #418
Conversation
lkostrowski
commented
Mar 4, 2025
•
edited
Loading
edited
- add NextRequest and NextResponse generics
🦋 Changeset detectedLatest commit: 79b58b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #418 +/- ##
==========================================
- Coverage 83.40% 81.66% -1.74%
==========================================
Files 99 107 +8
Lines 3429 3502 +73
Branches 587 593 +6
==========================================
Hits 2860 2860
- Misses 557 626 +69
- Partials 12 16 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
"types": "./util/public/browser/index.d.ts", | ||
"import": "./util/public/browser/index.mjs", | ||
"require": "./util/public/browser/index.js" | ||
}, |
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.
chaned exports - marked these for browser and node specific, removed some because they didn't make sense anymore
constructor(public request: Request) {} | ||
export class WebApiAdapter< | ||
TRequest extends Request = Request, | ||
TResponse extends Response = Response, |
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.
In general:
Before: Next App Router platform was 1:1 re-exported FetchApi. But this is not correct because Next is extending it's Request to NextREquest, so it was limiting the usage (and NextResponse too)
Now: I created separated code for Next, reused WebApi where possible and injected NextRequest and NextResponse as generics
Released snapshot build with Install it with: pnpm add @saleor/app-sdk@0.0.0-pr-20250304145310 |
package.json
Outdated
"types": "./verify-jwt.d.ts", | ||
"import": "./verify-jwt.mjs", | ||
"require": "./verify-jwt.js" | ||
"./auth/node": { |
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.
Question: do we support egde runtime as well or plan to do so?
I'm asking as if we don't plan to do this we can have auth/server
instead 🤔
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 think it's better if we keep node
for compatibility (I dont know if it works with edge) and then if we decide to support edge, we can add alias node = edge
or node = server
if we do other way around and start with "server" it will require a bc
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.
update: I dogfood it in Adyen and realized there is no "browser" part. JWT is from browser but it's checked on the server 🤦
So I removed node
and browser
and left auth
const context = validationResult.value; | ||
try { | ||
return await handlerFn(request, context); | ||
} catch (err) { |
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.
Question: don't we want to log error here (even if it is in debug)?
Released snapshot build with Install it with: pnpm add @saleor/app-sdk@0.0.0-pr-20250304160045 |
Released snapshot build with Install it with: pnpm add @saleor/app-sdk@0.0.0-pr-20250304161552 |
Released snapshot build with Install it with: pnpm add @saleor/app-sdk@0.0.0-pr-20250304162628 |