Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

bug(Plugins): when no register method is provided throws unhandled error #8

Open
Stradivario opened this issue Aug 31, 2019 · 0 comments
Assignees

Comments

@Stradivario
Copy link
Member

Stradivario commented Aug 31, 2019

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant