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

Need help in migrating Hapi application to v20.0.1 #4480

Closed
kurr2410 opened this issue Feb 13, 2024 · 1 comment
Closed

Need help in migrating Hapi application to v20.0.1 #4480

kurr2410 opened this issue Feb 13, 2024 · 1 comment
Assignees
Labels
support Questions, discussions, and general support

Comments

@kurr2410
Copy link

Runtime

Node.js

Runtime version

v16.20.2

Module version

^20.0.1

Used with

Hapi application

Any other relevant information

No response

How can we help?

I need to migrate a hapi.js application from v16.4.3 to ^20.0.1.
Since there are major changes made in v17.0.0 including reply() interface upgradation. Is there any optimal way to replace return reply() to return reply.reponse() in all the handlers?

//working code with  version v16.4.3(Hapi)
const addFoo = {
  description: 'add foo data',
  notes: 'add foo data',
  tags: ['api', 'FooCondition'],
  validate: {
    payload: {
      id: joi.number().required(),
    },
  },
  handler: (req, res) => {
    return maindb.subcategorymaster.findAll({
where: {'id': req.payload.id}
}).then((result) => {
      res(result);
    }).catch((DBException) => {
      res(DBException.message);
    });
  }
};

// Wanted to migrate to below code without making manual change at each and every handler.

//working code with version v20.0.1(Hapi)
const addFoo = {
  description: 'add foo data',
  notes: 'add foo data',
  tags: ['api', 'FooCondition'],
  validate: {
    payload: {
      id: joi.number().required(),
    },
  },
  handler: (req, res) => {
    return maindb.subcategorymaster.findAll({
where: {'id': req.payload.id}
}).then((result) => {
      return res.response(result);
    }).catch((DBException) => {
      return res.response(DBException.message);
    });
  }
};
@kurr2410 kurr2410 added the support Questions, discussions, and general support label Feb 13, 2024
@Nargonath
Copy link
Member

For major releases we have detailed migration explanations in GitHub issues labelled with "Breaking changes" and "Release notes" labels. Here are the one you'll need to go through considering your starting point and the destination version:

I don't think there is an automated or quick way for you to move from v16 API to v17+ API as the move to async/await kind of impacted the way you write your handlers.

I'll close this issue but we can keep the discussion going if needed.

@Nargonath Nargonath self-assigned this Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

2 participants