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

Error: Auth is not defined after having updated the hapi package #59

Open
advapiIT opened this issue Oct 14, 2020 · 0 comments
Open

Error: Auth is not defined after having updated the hapi package #59

advapiIT opened this issue Oct 14, 2020 · 0 comments

Comments

@advapiIT
Copy link

advapiIT commented Oct 14, 2020

Hello,
I've upgraded an old Nodejs project to the latest Hapi version... I've read your documentation but I got this error when I start the Nodejs application...

Here's my code

const init = async () => {

    const server = Hapi.server({
        port: port,
        host: 'localhost',
        routes: { cors: { credentials: true } }
    });

   
   

    // include our module here ↓↓, for example, require('hapi-auth-jwt2')
    
    await server.register(require('hapi-auth-jwt2'));

    server.auth.strategy('jwt', 'jwt',
        {
            key: 'SECRETKEYIHAVE', 
            validateFunc: Auth.login_validate,
            verifyOptions: { algorithms: ['HS256'] }// validate function defined above
        });

    server.auth.default('jwt');

    server.route(routes);

    await server.start();
    logger.info('Server running on %s', server.info.uri);

    return server;
};

process.on('unhandledRejection', (err) => {

    logger.error(err.message);
    process.exit(1);
});

init();

and here's my package.json

{
  "name": "aaa-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "boom": "^4.2.0",
    "dotenv": "^8.2.0",
    "@hapi/hapi": "^20.0.1",
    "hapi-auth-jwt2": "^10.0.2",
    "joi": "^10.2.0",
    "minimist": "^1.2.0",
    "mssql": "^3.3.0",
    "request": "^2.81.0",
    "tedious": "^1.14.0",
    "winston": "^3.3.3",
    "winston-daily-rotate-file": "^4.5.0",
    "xmlbuilder": "^8.2.2",
    "uuid": "^8.3.1",
    "seq-logging": "^0.4.6"
  }
}

Any suggestion?
Thanks in advance

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

No branches or pull requests

1 participant