You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since in hapi 17, all the joi errors return "Invalid payload" I want to implement this "failAction" in server routes config.
const hapiOptions = {
host: 'localhost',
port: 3000,
routes: {
validate: {
failAction: async (request, h, err) => {
if (process.env.NODE_ENV === 'production') {
// In prod, log a limited error message and throw the default Bad Request error.
console.error('ValidationError:', err.message); // Better to use an actual logger here.
throw Boom.badRequest(`Invalid request payload input`);
} else {
// During development, log and respond with the full error.
console.error(err);
throw err;
}
}
}
}
};
const server = Hapi.server(hapiOptions);
How can I implement this failAction with glue?
The text was updated successfully, but these errors were encountered:
You can just pass the routes property with your validate and failAction exactly as they appear in your example into the server object of your Glue manifest:
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
lockbot
locked as resolved and limited conversation to collaborators
Jan 9, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
supportQuestions, discussions, and general support
Since in hapi 17, all the joi errors return "Invalid payload" I want to implement this "failAction" in server routes config.
How can I implement this failAction with glue?
The text was updated successfully, but these errors were encountered: