Skip to content

Service class architecture silently ignores duplicate routes #2155

Open
@chris48s

Description

@chris48s

This is a bit of a contrived example, but if I declare something like:

class VersionService1 extends BaseJsonService {
  //stuff

  static get url() {
    return {
      base: 'someroute/v',
      format: '(.+)',
      capture: ['param'],
    }
  }
}

class VersionService2 extends BaseJsonService {
  //stuff

  static get url() {
    return {
      base: 'someroute/v',
      format: '(.+)',
      capture: ['param'],
    }
  }
}

module.exports = {
  VersionService1,
  VersionService2,
}

VersionService1 and VersionService2 are both trying to mount on the same route. When we start the server, one wins and one loses (I guess the order we register the services in is important here) but it doesn't throw an error. In the example above, it is pretty easy to debug, but once you've got services spread across multiple files this condition could become quite hard to detect.

It would be a nice safeguard if we added a check when we register the service classes which throws an error if we have declared any duplicate or conflicting routes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreServer, BaseService, GitHub auth, Shared helpersdeveloper-experienceDev tooling, test framework, and CI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions