Skip to content

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

@samifreesoul

Description

@samifreesoul

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions