Skip to content

Conversation

mushan0x0
Copy link
Contributor

@mushan0x0 mushan0x0 commented May 27, 2025

close #183

Copy link

vercel bot commented May 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-rest-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2025 6:26am
next-rest-framework-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2025 6:26am

@Hugo-Persson
Copy link

Hi!

I tried you changes locally but still get the issue

{"message":"Invalid path parameters.","errors":[{"code":"invalid_type","expected":"object","received":"promise","path":[],"message":"Expected object, received promise"}]}

Can I help debug this somehow?

Here is the route that is failing

const studyManifestResponseSchema = z.array(z.any());

const errorResponseSchema = z.object({
  error: z.string(),
});

const querySchema = z.object({
  range: z.string().optional(),
});

const getStudyManifestOperation = routeOperation({
  method: "GET",
})
  .input({
    params: z.object({
      studyId: z.string(),
    }),
    query: z.object({
      range: z.string().optional(),
    }),
  })
  .outputs([
    {
      status: 200,
      contentType: "application/octet-stream",
      body: studyManifestResponseSchema,
    },
    {
      status: 500,
      contentType: "application/json",
      body: errorResponseSchema,
    },
  ])
  .handler(async (request: Request, extra) => {
    try {
      const params = extra.params;
      console.log("Params", params);

      return TypedNextResponse.json(
        { error: "..." },
        { status: 200 },
      );
    } catch (error) {
      return TypedNextResponse.json(
        { error: "..." },
        { status: 500 },
      );
    }
  });

export const { GET } = route({
  getStudyManifest: getStudyManifestOperation,
});

@mushan0x0
Copy link
Contributor Author

Hi!

I tried you changes locally but still get the issue

{"message":"Invalid path parameters.","errors":[{"code":"invalid_type","expected":"object","received":"promise","path":[],"message":"Expected object, received promise"}]}

Can I help debug this somehow?

Here is the route that is failing

const studyManifestResponseSchema = z.array(z.any());

const errorResponseSchema = z.object({
  error: z.string(),
});

const querySchema = z.object({
  range: z.string().optional(),
});

const getStudyManifestOperation = routeOperation({
  method: "GET",
})
  .input({
    params: z.object({
      studyId: z.string(),
    }),
    query: z.object({
      range: z.string().optional(),
    }),
  })
  .outputs([
    {
      status: 200,
      contentType: "application/octet-stream",
      body: studyManifestResponseSchema,
    },
    {
      status: 500,
      contentType: "application/json",
      body: errorResponseSchema,
    },
  ])
  .handler(async (request: Request, extra) => {
    try {
      const params = extra.params;
      console.log("Params", params);

      return TypedNextResponse.json(
        { error: "..." },
        { status: 200 },
      );
    } catch (error) {
      return TypedNextResponse.json(
        { error: "..." },
        { status: 500 },
      );
    }
  });

export const { GET } = route({
  getStudyManifest: getStudyManifestOperation,
});

You can directly follow this comment for usage, the code in this PR also comes from here #183 (comment)

@Hugo-Persson
Copy link

Hi!
I tried you changes locally but still get the issue

{"message":"Invalid path parameters.","errors":[{"code":"invalid_type","expected":"object","received":"promise","path":[],"message":"Expected object, received promise"}]}

Can I help debug this somehow?
Here is the route that is failing

const studyManifestResponseSchema = z.array(z.any());

const errorResponseSchema = z.object({
  error: z.string(),
});

const querySchema = z.object({
  range: z.string().optional(),
});

const getStudyManifestOperation = routeOperation({
  method: "GET",
})
  .input({
    params: z.object({
      studyId: z.string(),
    }),
    query: z.object({
      range: z.string().optional(),
    }),
  })
  .outputs([
    {
      status: 200,
      contentType: "application/octet-stream",
      body: studyManifestResponseSchema,
    },
    {
      status: 500,
      contentType: "application/json",
      body: errorResponseSchema,
    },
  ])
  .handler(async (request: Request, extra) => {
    try {
      const params = extra.params;
      console.log("Params", params);

      return TypedNextResponse.json(
        { error: "..." },
        { status: 200 },
      );
    } catch (error) {
      return TypedNextResponse.json(
        { error: "..." },
        { status: 500 },
      );
    }
  });

export const { GET } = route({
  getStudyManifest: getStudyManifestOperation,
});

You can directly follow this comment for usage, the code in this PR also comes from here #183 (comment)

I tried that patch as well but still get error. Do I need to change my code in some way?

(cherry picked from commit 7e519c2)
@mushan0x0
Copy link
Contributor Author

@Hugo-Persson I have just submitted this part of code SaadBazaz@7e519c2 , why don't you try it again?

@Hugo-Persson
Copy link

@Hugo-Persson I have just submitted this part of code SaadBazaz@7e519c2 , why don't you try it again?

Yes it works now! Thank you!

Can I use your branch as an NPM package before being merged instead of compiling locally?

@mushan0x0
Copy link
Contributor Author

Yes it works now! Thank you!

Can I use your branch as an NPM package before being merged instead of compiling locally?

You can fork my repository to publish your own package or wait for the author to merge and release.

@blomqma blomqma merged commit 575718e into blomqma:main Jun 11, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Does not work with Next 15

5 participants