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

[core]: bug(Plugins): when no register method is provided throws unhandled error #46

Open
Stradivario opened this issue Oct 5, 2021 · 0 comments

Comments

@Stradivario
Copy link
Member

Stradivario commented Oct 5, 2021

Issue is migrated from rxdi/core#8

This error is leading to missunderstanding of what is happening with the platform in this period of time

Provided this plugin

import { Inject, Plugin } from '@rxdi/core';
import { HAPI_SERVER } from '@rxdi/hapi';
import { Server } from 'hapi';

@Plugin()
export class ServeComponents {
  constructor(@Inject(HAPI_SERVER) private server: Server) {}

}

Throws error

TypeError: plugin.register is not a function
    at BootstrapService.<anonymous> (/home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/@rxdi/core/dist/services/bootstrap/bootstrap.service.js:147:26)
    at Generator.next (<anonymous>)
    at /home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/@rxdi/core/dist/services/bootstrap/bootstrap.service.js:16:71
    at new Promise (<anonymous>)
    at __awaiter (/home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/@rxdi/core/dist/services/bootstrap/bootstrap.service.js:12:12)
    at BootstrapService.registerPlugin (/home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/@rxdi/core/dist/services/bootstrap/bootstrap.service.js:145:16)
    at BootstrapService.<anonymous> (/home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/@rxdi/core/dist/services/bootstrap/bootstrap.service.js:118:94)
    at Generator.next (<anonymous>)
    at /home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/@rxdi/core/dist/services/bootstrap/bootstrap.service.js:16:71
    at new Promise (<anonymous>)
    at __awaiter (/home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/@rxdi/core/dist/services/bootstrap/bootstrap.service.js:12:12)
    at pluginService.getPlugins.filter.map (/home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/@rxdi/core/dist/services/bootstrap/bootstrap.service.js:118:29)
    at Array.map (<anonymous>)
    at BootstrapService.asyncChainablePluginsRegister (/home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/@rxdi/core/dist/services/bootstrap/bootstrap.service.js:118:18)
    at SwitchMapSubscriber.rxjs_1.combineLatest.pipe.operators_1.switchMap [as project] (/home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/@rxdi/core/dist/services/bootstrap/bootstrap.service.js:59:554)
    at SwitchMapSubscriber._next (/home/rampage/Desktop/work/repos/public/graphql-server-from-json/node_modules/rxjs/internal/operators/switchMap.js:49:27)

Correct situation

import { Inject, Plugin } from '@rxdi/core';
import { HAPI_SERVER } from '@rxdi/hapi';
import { Server } from 'hapi';

@Plugin()
export class ServeComponents {
  constructor(@Inject(HAPI_SERVER) private server: Server) {}

  async register() {
    this.server.route({
        method: 'GET',
        path: '/devtools/{param*}',
        handler: {
          directory: {
            path: `${__dirname.replace('dist/services', '')}/public`,
            index: ['index.html', 'default.html']
          }
        }
      });
  }

}
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