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

can't register hoodie plugin in hapi: Invalid register options "value" must be of type object #904

Open
asedsami opened this issue Aug 4, 2020 · 2 comments

Comments

@asedsami
Copy link

asedsami commented Aug 4, 2020

Hi. I'm trying to use hoodie plugin in hapi but have failed to do so. Here's my index.js:

'use strict';

const Hapi = require('@hapi/hapi');
const hoodie = require('hoodie')
const PouchDB = require('pouchdb-core')
  .plugin(require('pouchdb-mapreduce'))
  .plugin(require('pouchdb-adapter-memory'))


const init = async () => {
    const server = Hapi.server({
        port: 3000,
        host: 'localhost'
    })

    await server.register({
      plugin: {
        name: 'hoodiePlugin',
        register: hoodie.register,
      },
      options: {
        inMemory: true,
        public: 'public',
        data: '.hoodie',
        PouchDB,
      }
    })

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

process.on('unhandledRejection', (err) => {
    console.log(err);
    process.exit(1);
});

init();


I'm new to hoodie and hapi, I created a simple plugin and it worked but when I tried registering the hoodie plugin and then started the server, I got this error:

Error: Invalid register options  "value" must be of type object
    at Object.exports.apply (/home/asedsami/workspace/hoodie-plugin/node_modules/@hapi/hapi/lib/config.js:19:15)
    at internals.Server.register (/home/asedsami/workspace/hoodie-plugin/node_modules/@hapi/hapi/lib/server.js:416:26)
    at Object.register (/home/asedsami/workspace/hoodie-plugin/node_modules/hoodie/server/index.js:24:10)
    at internals.Server.register (/home/asedsami/workspace/hoodie-plugin/node_modules/@hapi/hapi/lib/server.js:488:35)
    at init (/home/asedsami/workspace/hoodie-plugin/index.js:60:18)
    at Object.<anonymous> (/home/asedsami/workspace/hoodie-plugin/index.js:83:1)
    at Module._compile (internal/modules/cjs/loader.js:1256:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
    at Module.load (internal/modules/cjs/loader.js:1105:32)
    at Function.Module._load (internal/modules/cjs/loader.js:967:14)

Thanks for any help you're able to provide.

@asedsami asedsami changed the title can't register hoodie plugin: Invalid register options "value" must be of type object can't register hoodie plugin in hapi: Invalid register options "value" must be of type object Aug 5, 2020
@bitfede
Copy link

bitfede commented Sep 3, 2020

interested to know a solution to this as well!! Having the same issue!

@DanteHaxor
Copy link

I think this will solve the above error

'use strict';

const Hapi = require('@hapi/hapi');
const hoodie = require('hoodie');
const PouchDB = require('pouchdb-core')
  .plugin(require('pouchdb-mapreduce'))
  .plugin(require('pouchdb-adapter-memory'));

const init = async () => {
  const server = Hapi.server({
    port: 3000,
    host: 'localhost'
  });

  await server.register({
    plugin: hoodie.plugin,
    options: {
      inMemory: true,
      public: 'public',
      data: '.hoodie',
      PouchDB
    }
  });

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

process.on('unhandledRejection', (err) => {
  console.log(err);
  process.exit(1);
});

init();

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

3 participants