Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

root service is for /api, not / #12

Open
mariusa opened this issue Mar 16, 2021 · 3 comments
Open

root service is for /api, not / #12

mariusa opened this issue Mar 16, 2021 · 3 comments

Comments

@mariusa
Copy link

mariusa commented Mar 16, 2021

To Reproduce

http://localhost:5000/api gives

{"message":"Hello Fastify!"}

Expected behavior

http://localhost:5000/ to work instead
A clear and concise description of what you expected to happen.

Cause:

 fastify.register(AutoLoad, {
        dir: path.join(__dirname, 'services'),
        options: Object.assign({ prefix: '/api' }, opts)
    })

Please make root handle '/', so I can see an example of routes with prefix, other routes with some other prefix, and routes with no prefix.

Thanks!

@mcollina
Copy link
Member

would you be able to send a PR?

@mariusa
Copy link
Author

mariusa commented Mar 16, 2021

Yes. What would you recommend as best practice?

  1. change prefix to / here
    https://github.com/fastify/fastify-example-todo/blob/master/app.js#L32

  2. move auth.js and todo.js in /services/api/
    (seems strange to require an extra folder, most services are apis except just something in /)
    ?

@mcollina
Copy link
Member

I would add that folder, yes. I would also recommend all the modules to be updated as this is likely out of date

@mariusa mariusa mentioned this issue Mar 16, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants