Skip to content
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 a HOF for wrapping getServerSideProps handlers #90

Merged
merged 10 commits into from
Feb 9, 2023

Conversation

haydn
Copy link
Contributor

@haydn haydn commented Dec 18, 2022

  • Add withAxiomNextServerSidePropsHandler
  • Export all withAxiom functions
  • Change type signature for withAxiomNextApiHandler
  • Change type signature for withAxiom

- Add withAxiomNextServerSidePropsHandler
- Export all withAxiom functions
- Change type signature for withAxiomNextApiHandler
- Change type signature for withAxiom
@vercel
Copy link

vercel bot commented Dec 18, 2022

@haydn is attempting to deploy a commit to the AxiomFM Team on Vercel.

A member of the Team first needs to authorize it.

@haydn
Copy link
Contributor Author

haydn commented Dec 18, 2022

I still need to do a bit of testing and update the README before that marking this ready for review. Also, the changes to the type signatures might be considered a breaking change — would it better to keep that out of this PR?

@schehata
Copy link
Collaborator

schehata commented Jan 4, 2023

hey @haydn thanks for your contribution! I will take a look right now.

@schehata schehata self-assigned this Jan 4, 2023
src/withAxiom.ts Outdated Show resolved Hide resolved
@schehata
Copy link
Collaborator

schehata commented Jan 4, 2023

all looks good, can you add an example for usage in the examples folder?

Maybe we can add this to the README:

## getServerSideProps

To be able to use next-axiom with `getServerSideProps` you need to wrap your function with `withAxiomGetServerSideProps`, becasue there is no
way at the moment to automatically detected if getServerSideProps is used.

```ts
import { withAxiomGetServerSideProps } from 'next-axiom'
export const getServerSideProps = withAxiomGetServerSideProps(async ({ req, log })  => {
  log.info('Hello, world!');
  return {
    props: {
    },
  }
});

@schehata
Copy link
Collaborator

schehata commented Jan 4, 2023

oh I remembered one more thing, we will need to export the new types in src/index.ts so that the types would be available for next-axiom users.

@vercel
Copy link

vercel bot commented Jan 26, 2023

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

Name Status Preview Comments Updated
next-axiom-example ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 27, 2023 at 10:08AM (UTC)

@schehata
Copy link
Collaborator

I made some changes, but I wasn't able to write a good test for this, as I am not able to use expect against type AxiomGetServierSideProps. any ideas to improve this? @bahlo @haydn

@schehata schehata requested a review from bahlo January 26, 2023 09:19
@schehata schehata merged commit 0b17e82 into axiomhq:main Feb 9, 2023
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.

None yet

4 participants