vvo / iron-session

🛠 Secure, stateless, and cookie-based session library for JavaScript
https://get-iron-session.vercel.app
MIT License
3.65k stars 251 forks source link

Migration away from `withIronSessionApiRoute` #679

Closed elie222 closed 4 months ago

elie222 commented 10 months ago

Upgrading from v6 to v8 of this package. What's the easiest way to migrate withIronSessionApiRoute?

mschilde commented 9 months ago

+1 on this. Is there an upgrade guide?

sacru2red commented 7 months ago

in my cases,

export default withIronSessionApiRoute(
  async function handler (
    req: NextApiRequest,
    res: NextApiResponse,
  ) {

 ...
}, IronSessionOptions)
export default async function handler (
    req: NextApiRequest,
    res: NextApiResponse,
) {
    const session = await getIronSession<ApiResonseData>(req, res, IronSessionOptions)
   ...
}
mattcasey commented 7 months ago

Here's the OG source code: https://github.com/vvo/iron-session/blob/v6/next/index.ts

vvo commented 4 months ago

Yep this is how it was done previously: https://github.com/vvo/iron-session/blob/70d2ff14aacb51e83284d51832fdcda539b4dabc/next/index.ts#L19-L46