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

Error: New route X conflicts with existing Y #1

Closed
krnlde opened this issue Mar 11, 2016 · 9 comments
Closed

Error: New route X conflicts with existing Y #1

krnlde opened this issue Mar 11, 2016 · 9 comments
Assignees

Comments

@krnlde
Copy link

krnlde commented Mar 11, 2016

{
        {
            params: '/{id}/note/{noteId}',
            method: 'PUT'
        },
        {
            params: '/{id}/note/{noteId}',
            method: 'PATCH'
        }
}

This should work since there are different methods to the same endpoint, but it fails with the following message: Error: New route /api/salesItem/{id}/note/{noteId} conflicts with existing /api/salesItem/{id}/note/{noteId}

@krnlde krnlde changed the title Error: New route /api/salesItem/{id}/note/{noteId} conflicts with existing /api/salesItem/{id}/note/{noteId} Error: New route X conflicts with existing Y Mar 11, 2016
@mischah
Copy link
Member

mischah commented Mar 11, 2016

Yeah. Right. I loop through the urls array to create server routes. So that can’t work.

But I see the need to have multiple methods for one route but I would prefer the following approach.

Instead of:

urls: [
  {
    params: '/{id}/note/{noteId}',
    response: '/json-templates/foo.json',
    method: 'PUT'
  },
  {
    params: '/{id}/note/{noteId}',
    response: '/json-templates/foo.json',
    method: 'PATCH'
  }
]

I would define this route via

urls: [
  {
    params: '/{id}/note/{noteId}',
    response: '/json-templates/foo.json',
    methods: ['PUT', 'PATCH']
  }
]

Feedback appreciated @krnlde @revrng

Edit:

Could it be a usecase to have:

  • one route
  • multiple methods
    • different responses for each method?

In that case we would have to use something like:

urls: [
  {
    params: '/{id}/note/{noteId}',
    response: {
      PUT: '/json-templates/foo.json',
      PATCH: { success: true }
    }
  }
]

or

urls: [
  {
    params: '/{id}/note/{noteId}',
    responses: [
      { method: 'PUT',
        response: '/json-templates/foo.json' },
      { method: 'PATCH',
       response: { success: true } }
    ]
  }
]

@krnlde
Copy link
Author

krnlde commented Mar 11, 2016

What if I need another response for PUT than for PATCH?

@mischah
Copy link
Member

mischah commented Mar 11, 2016

See above ⬆️

@krnlde
Copy link
Author

krnlde commented Mar 11, 2016

D'accord

@mischah
Copy link
Member

mischah commented Mar 11, 2016

The question is which of the two approaches is less ugly :neckbeard:

I guess I would prefer the latter one.
The first one might be more readable. But I hate to misuse keys (eg. PUT) as values.

@krnlde
Copy link
Author

krnlde commented Mar 11, 2016

The latter is the better for me. I think you can also omit the success: true part for convenience. It should be treated the same way (implicit 200 OK)

@mischah
Copy link
Member

mischah commented Mar 11, 2016

The { success: true } thingie ist just an example for returning a JavaScript object instead of the content of a JSON file.

This is an already existing feature. See README or tests 😏

@mischah mischah self-assigned this Mar 11, 2016
@krnlde
Copy link
Author

krnlde commented Mar 11, 2016

Cooool. I'm new, so sorry for being stupid :)

@mischah
Copy link
Member

mischah commented Mar 11, 2016

Haha. My pleasure 😆

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

2 participants