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

support for isolated routes to solve multiple instances problem #171

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

andrefelipeschulle
Copy link

@andrefelipeschulle andrefelipeschulle commented Nov 14, 2024

This modification solves the issue of isolating routes and adding more swagger instances in Elysia using app.group() and uses the elysia routes api which gets the routes from the context

fix #138

const firstApp = new Elysia({ prefix: '/first' })

firstApp
	.get('/first-route', () => {
		return 'first route!'
	})
	.use(
		swagger({
			path: '/first-doc',
			routes: firstApp.routes
		})
	)

const secondApp = new Elysia({ prefix: '/second' })

secondApp
	.get('/second-route', () => {
		return 'second route!'
	})
	.use(
		swagger({
			path: '/second-doc',
			routes: secondApp.routes
		})
	)

const app = new Elysia({
	// aot: false
})
	.use(firstApp)
	.use(secondApp)
	.listen(3000)

this way we can isolate into groups and have two instances with different paths and separate the documentation without needing a lot of code

@andrefelipeschulle
Copy link
Author

just an idea that helps in specific cases without changing the code too much and without breaking any part of the plugin

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

Successfully merging this pull request may close these issues.

How to use Swagger for multiple instances?
1 participant