-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
TypeScript clarification #44
Comments
I think there might be a bug in the code! Would you like to send a fix? |
I can look into it, but if you know what it is it may just be faster for you to. I hadn't looked too hard into the code, I just figured maybe I was screwing up somewhere |
In fiddling around some more it seems to actually be an issue with how |
|
the issue seems to come down to the Edit Gonna try something. will let you know if it works or not. If it does I'll |
Workingthe first line is for a TS file that is wrapping the exported function in Not WorkingThis will no longer work -- if compatibility with the |
@mcollina not sure if you saw my other comments. |
Compatibility with fastify-plugin is expected. It works in Javascript, so it should work on TS as well. |
Alright, I'll look into what can be done to resolve the issue -- might take me a bit since I'm swamped with my 9-5 right now, and I'm going to have to look into fastify-plugin to determine what's going on from that end. |
Random Update: This appears to be a problem not only with TypeScript, but with autoloads interactions with Doesn't Work
Works
|
That looks like a bug! Would you like to send a PR to fix it? |
I'll try to. Looking into how it all works together to determine if it's something that should be fixed on fastify plugin's side or autoload's side. |
After some fiddling I'm left with a question: What exactly does the I've read the only available doc that I could find (https://github.com/fastify/fastify/blob/master/docs/Plugins.md) but it doesn't really do a whole lot in-depth. |
That’s exactly the use that fastify-plugin provides. It’s _built_ for that.
Il giorno lun 26 ago 2019 alle 18:53 Jim Burbridge <notifications@github.com>
ha scritto:
… After some fiddling I'm left with a question: What exactly does the
Symbol.for('skip-override') part do? It seems to be that is the cause of
the issue with routes not listening to the prefix, though I'm fuzzy as to
*why*. If I take a service that currently does work with the autoPrefix,
and add module.exports[Symbol.for('skip-override')] = true it fails just
as though I was using fastify-plugin.
I've read the only available doc that I could find (
https://github.com/fastify/fastify/blob/master/docs/Plugins.md) but it
doesn't really do a whole lot in-depth.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#44?email_source=notifications&email_token=AAAMXY73H2C6LG6NBXAYPWDQGQC7PA5CNFSM4IHN3IGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5E6VJA#issuecomment-524937892>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAMXY2ERDA4DH6QNZUYYHTQGQC7PANCNFSM4IHN3IGA>
.
|
I honestly can't see anything in the fastify-autoload code that would be causing that, so this bug might lead me down into the regular fastify repo. I'm at work now, so I'll check after I'm done for the day. |
I decided to test my hypothesis by creating a quick example that did not use fastify autoload or plugin but did use the The results are the same -- a plugin called with the skip-override set to true ignores it's passed prefix, and a plugin registered without it does not. I'm assuming this bug is therefore an issue with the fastify base itself, and not with |
@jhechtf it's not a bug, it's how fastify works. It's documented in https://www.fastify.io/docs/latest/Plugins/#route-prefixing-option. |
@jhechtf I just started running into this problem today in a new project. Did you ever get around this? |
Now we get 404 there |
Tl;DR: Can't get the autoPrefix thing to work with TS files & ts-node.
I've tried to use autoPrefix two ways with TypeScript files, and I cannot seem to find a way to it to work as expected.
Things I've tried
First Attempt
I tried to add the options.prefix to the Autoload call, like so
This only adds in the
/user
route, and not/api/user
Second Attempt
Basically the same server.ts setup, minus the options object.
In both cases
/api/user
is not found, but/user
is.Any tips on how to fix this? I'd be happy to submit a pull request for the documentation once I have a solution.
The text was updated successfully, but these errors were encountered: