Skip to content
This repository was archived by the owner on Oct 5, 2021. It is now read-only.
This repository was 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

@Stradivario

Description

@Stradivario

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']
          }
        }
      });
  }

}

Metadata

Metadata

Assignees

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