diff --git a/src/server/components/Registry.js b/src/server/components/Registry.js index e329301..da182a1 100644 --- a/src/server/components/Registry.js +++ b/src/server/components/Registry.js @@ -11,6 +11,7 @@ class Registry { this.endpoints = new Collection(); this.path = options.path; this.server = server; + this.logger = server.createLogger(this); } get print () { @@ -29,7 +30,7 @@ class Registry { async loadEndpoints () { - const { server, endpoints } = this; + const { server, endpoints, logger } = this; return (async function read (pth) { @@ -44,11 +45,16 @@ class Registry { const Endpoint = require(file); if (!Endpoint) continue; + if (typeof Endpoint !== 'function') { + logger.warn(`Attempted to instantiate invalid class at ${file.name}`); + continue; + } const endpoint = new Endpoint(server); endpoint.init(); if (endpoints.has(endpoint.resolveable)) throw new Error(`Error registering endpoint ${endpoint.resolveable}: an endpoint with that resolveable already exists`); endpoints.set(endpoint.resolveable, endpoint); + logger.info(`Created endpoint ${endpoint.name}`); }