question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Method 'GET' already declared for route '/myRoute' with constraints '{}'

See original GitHub issue

Hey hey! 👋🏼

I encountered this error

/platformatic/node_modules/.pnpm/find-my-way@7.3.1/node_modules/find-my-way/index.js:301
      throw new Error(`Method '${method}' already declared for route '${path}' with constraints '${JSON.stringify(constraints)}'`)
            ^

Error: Method 'GET' already declared for route '/myRoute' with constraints '{}'
    at Router._on (/platformatic/node_modules/.pnpm/find-my-way@7.3.1/node_modules/find-my-way/index.js:301:13)
    at Router.on (/platformatic/node_modules/.pnpm/find-my-way@7.3.1/node_modules/find-my-way/index.js:136:10)
    at Object.addNewRoute (/platformatic/node_modules/.pnpm/fastify@4.10.2/node_modules/fastify/lib/route.js:301:16)
    at Object.route (/platformatic/node_modules/.pnpm/fastify@4.10.2/node_modules/fastify/lib/route.js:217:19)
    at Object.prepareRoute (/platformatic/node_modules/.pnpm/fastify@4.10.2/node_modules/fastify/lib/route.js:150:18)
    at Object._get [as get] (/platformatic/node_modules/.pnpm/fastify@4.10.2/node_modules/fastify/fastify.js:249:34)
    at entityPlugin (/platformatic/packages/sql-openapi/lib/entity-to-routes.js:111:9)
    at Plugin.exec (/platformatic/node_modules/.pnpm/avvio@8.2.0/node_modules/avvio/plugin.js:130:19)
    at Boot.loadPlugin (/platformatic/node_modules/.pnpm/avvio@8.2.0/node_modules/avvio/plugin.js:272:10)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Can we add logic to create unique routes or detect duplicates (and do something with them without throwing)? 😊

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
marcopiraccinicommented, Dec 22, 2022

I think this the the origin of the issue (two FK on the same entities). We should check that we use the properties keys for the nested api and not the entity names.

CONSTRAINT `table2_custom_id_foreign_idx` FOREIGN KEY (`custom_id`) REFERENCES `table1` (`id`),
CONSTRAINT `table2_fk_id_foreign_idx` FOREIGN KEY (`fk_id`) REFERENCES `table1` (`id`)
1reaction
mcollinacommented, Dec 23, 2022

@rozzilla would you like to send a PR for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

AssertionError: Method 'GET' already declared for route #33
I came across this (still failing) test case while thinking a general solution for the issue #29 (comment) test('Similar route path, ...
Read more >
Routes - Fastify
You have two ways to declare a route with Fastify: the shorthand method and the full declaration. Full declaration; Routes options; Shorthand declaration;...
Read more >
How to assign routes within a base route in fastify
For the base route to work globally in all routes, you can register it in your server.js or app.js whatever you are using...
Read more >
Using Reactive Routes - Quarkus
Reactive routes propose an alternative approach to implement HTTP endpoints where you declare and chain routes. This approach became very popular in the ......
Read more >
Route configuration | OpenShift Container Platform 4.9
The following procedure describes how to create a simple HTTP-based route to a web application, using the hello-openshift application as an example.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found