-
Notifications
You must be signed in to change notification settings - Fork 1
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
Using Elysia prefix adds the prefix at the END of all auto loaded paths #3
Comments
new version should fix this |
Ohh sorry i forgot about prefix in eden type generation fixed with elysia-autoload@0.1.7 |
Using 0.1.7
export const app = new Elysia({
prefix: '/api',
})
.use(
autoload({
pattern: '**/index.ts',
dir: path.resolve(process.cwd(), 'src/routes/api/[...catchall]'
),
types: {
output: '../lib/elysia/route-types.ts',
},
}),
)
.use(
swagger({
path: '/docs',
}),
)
getting the prefix added to the end of the types here but routing works!
[image: image.png]
…On Tue, Mar 12, 2024 at 2:01 AM Kravets ***@***.***> wrote:
- ***@***.***
new version should fix this
Ohh sorry i forgot about prefix in eden type generation
—
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACFY5BMXV7FWTBVS4WZUQNLYXYZUHAVCNFSM6AAAAABERCJW2SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBZGYYDMOJUHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Can you send me image again? |
Sorry it was a list of intellisense for the API after the prefix is removed
from the plugin params and using the prefix in elysia initializer instead
export const app = new Elysia({
prefix: '/api'
})
.use(
autoload({
// anything that is an index.ts or [something].ts (string arg)
pattern: "**/{index.ts,[[]*[]].ts}",
dir: path.resolve(process.cwd(), "src/routes/api/[...catchall]"
),
types: {
output: path.resolve(process.cwd(), "
src/elysia/elysia-types.ts"),
},
}),
)
.use(
swagger({
path: "/docs",
}),
)
The types in the ts file are:
declare global {
export type Routes = ElysiaWithBaseUrl<"/", ReturnType<typeof Route0>>
& ElysiaWithBaseUrl<"/groups/:id", ReturnType<typeof Route1>>
& ElysiaWithBaseUrl<"/users/:id", ReturnType<typeof Route2>>
}
But they show up in intellisense like so:
"/api"
"/groups/:id/api"
"/users/:id/api"
…On Tue, Mar 12, 2024 at 12:48 PM Kravets ***@***.***> wrote:
Using 0.1.7
export const app = new Elysia({
prefix: '/api',
})
.use(
autoload({
pattern: '**/index.ts',
dir: path.resolve(process.cwd(), 'src/routes/api/[...catchall]'
),
types: {
output: '../lib/elysia/route-types.ts',
},
}),
)
.use(
swagger({
path: '/docs',
}),
)
getting the prefix added to the end of the types here but routing works!
[image: image.png]
On Tue, Mar 12, 2024 at 2:01 AM Kravets *@*.***> wrote:
- *@*.***
new version should fix this
Ohh sorry i forgot about prefix in eden type generation
—
Reply to this email directly, view it on GitHub
#3 (comment)
<#3 (comment)>
,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACFY5BMXV7FWTBVS4WZUQNLYXYZUHAVCNFSM6AAAAABERCJW2SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBZGYYDMOJUHE
.
You are receiving this because you authored the thread.Message ID:
*@*.***>
Can you send me image again?
—
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACFY5BIU26WO6MZHHYE5SD3YX3FNVAVCNFSM6AAAAABERCJW2SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJRGIYDIMBQGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Heya, I made a PR to address this and make the plugin be able to use the main instance's "prefix" config, but make it only apply to the types: |
If you add the prefix to Elysia,
then the routes will have the prefix added at the END.
This causes issues with subsequent plugins like Swagger, I'd have to add the prefix to the swagger
path
parameter and then i have to add some middleware to remove the double prefix.Am i using it incorrectly? shouldn't it play nice with the Elysia native prefix?
Thanks!
The text was updated successfully, but these errors were encountered: