qstash-js icon indicating copy to clipboard operation
qstash-js copied to clipboard

feat: change import paths

Open ogzhanolguncu opened this issue 1 year ago • 4 comments

This PR

  • Replaces biome with eslint for stricter linting.
  • Adds prettier.js
  • Adds bun for test and runtime
  • Unidici for header and body types
  • Husky for hooks
  • Commitlint for stricter commit conventions
  • Fixes import paths. imports no longer require /dist/nextjs or /dist. This might break existing import paths.

ogzhanolguncu avatar May 08 '24 10:05 ogzhanolguncu

Looks like this does cause existing imports to be broken. Followed the Nextjs quickstart and got this after step 5.

Package path ./dist/nextjs is not exported from package 

Also getting this type error

Argument of type '(request: Request) => Promise<Response>' is not assignable to parameter of type '((request: Request) => VerifySignatureAppRouterResponse) | ((request: NextRequest) => VerifySignatureAppRouterResponse)'.
  Type '(request: Request) => Promise<Response>' is not assignable to type '(request: Request) => VerifySignatureAppRouterResponse'.
    Type 'Promise<Response>' is not assignable to type 'VerifySignatureAppRouterResponse'.
      Type 'Promise<Response>' is not assignable to type 'Promise<NextResponse<unknown>>'.
Type 'Response' is missing the following properties from type 'NextResponse<unknown>': cookies, [INTERNALS]

for

import { verifySignatureAppRouter } from "@upstash/qstash/nextjs";

async function handler(request: Request) {
  const data = await request.json();

  for (let i = 0; i < 10; i++) {
    await fetch('https://firstqstashmessage.requestcatcher.com/test', {
      method: 'POST',
      body: JSON.stringify(data),
      headers: { 'Content-Type': 'application/json' }
    });
    await new Promise(resolve => setTimeout(resolve, 500));
  }


  return Response.json({ success: true });
}

export const POST = verifySignatureAppRouter(handler);

MeshanKhosla avatar May 12 '24 20:05 MeshanKhosla

Looks like this does cause existing imports to be broken. Followed the Nextjs quickstart and got this after step 5.

Package path ./dist/nextjs is not exported from package 

Also getting this type error

Argument of type '(request: Request) => Promise<Response>' is not assignable to parameter of type '((request: Request) => VerifySignatureAppRouterResponse) | ((request: NextRequest) => VerifySignatureAppRouterResponse)'.
  Type '(request: Request) => Promise<Response>' is not assignable to type '(request: Request) => VerifySignatureAppRouterResponse'.
    Type 'Promise<Response>' is not assignable to type 'VerifySignatureAppRouterResponse'.
      Type 'Promise<Response>' is not assignable to type 'Promise<NextResponse<unknown>>'.
Type 'Response' is missing the following properties from type 'NextResponse<unknown>': cookies, [INTERNALS]

for

import { verifySignatureAppRouter } from "@upstash/qstash/nextjs";

async function handler(request: Request) {
  const data = await request.json();

  for (let i = 0; i < 10; i++) {
    await fetch('https://firstqstashmessage.requestcatcher.com/test', {
      method: 'POST',
      body: JSON.stringify(data),
      headers: { 'Content-Type': 'application/json' }
    });
    await new Promise(resolve => setTimeout(resolve, 500));
  }


  return Response.json({ success: true });
}

export const POST = verifySignatureAppRouter(handler);

Yeah, sadly this change is breaking existing imports. And, I'll check nextjs import and make sure it works like this: @upstash/qstash/nextj

ogzhanolguncu avatar May 12 '24 20:05 ogzhanolguncu

@MeshanKhosla imports should be fixed now, if there is anything wrong ping me

ytkimirti avatar May 14 '24 16:05 ytkimirti