axiomhq/next-axiom

Typescript support?

mclean25 opened this issue · 4 comments

Perhaps I'm missing something obvious here, but I can't see anywhere in the docs where we can add the type declaration to the NextApiRequest type to be able to do req.log.

Did some digging into the source, and I've deduced my own type to get by for now. This definitely feels like something that should come out of box though.

interface AxiomNextApiRequest extends NextApiRequest {
  log: AxiomLogger;
}

interface AxiomLogger {
  info: (message: string, args?: any) => void;
  debug: (message: string, args?: any) => void;
  error: (message: string, args?: any) => void;
  log: (message: string, args?: any) => void;
}

Oh, I found AxiomAPIRequest. Probably a good idea to add this to the docs. I'll leave this open to remind myself to submit a PR.

bahlo commented

Hey @mclean25, very good point, we should probably have typescript docs too 👍

bahlo commented

Closing, we changed our docs in the README.md to TypeScript 🙌