Skip to content

Commit c41c3ee

Browse files
committed
refactor(provider): allow more customization
1 parent dc4e4a0 commit c41c3ee

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

providers/transmit_provider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ export default class TransmitProvider {
6565
return ctx.response.noContent()
6666
})
6767

68-
if (config.routeHandlerDomain) {
69-
registerRoute.domain(config.routeHandlerDomain)
70-
subscribeRoute.domain(config.routeHandlerDomain)
71-
unsubscribeRoute.domain(config.routeHandlerDomain)
68+
if (config.routeHandlerModifier) {
69+
config.routeHandlerModifier(registerRoute)
70+
config.routeHandlerModifier(subscribeRoute)
71+
config.routeHandlerModifier(unsubscribeRoute)
7272
}
7373
}
7474

src/types/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
import type { TransportFactory } from '@rlanz/bus/types/main'
11+
import type { Route } from '@adonisjs/core/http'
1112

1213
/**
1314
* A Duration can be a number in milliseconds or a string formatted as a duration
@@ -26,5 +27,5 @@ export type Broadcastable = { [key: string]: Broadcastable } | string | number |
2627
export interface TransmitConfig {
2728
pingInterval?: Duration | false
2829
transport: null | { driver: TransportFactory; channel?: string }
29-
routeHandlerDomain?: string
30+
routeHandlerModifier?: (route: Route) => void
3031
}

tests/transmit_provider.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ test.group('Provider', () => {
2626
assert.equal((router.routes[2] as Route).getPattern(), '__transmit/unsubscribe')
2727
})
2828

29-
test('allow to customize the domain of the routes', async ({ assert }) => {
29+
test('allow to customize the route registration', async ({ assert }) => {
3030
const app = await setupApp({
3131
transmit: {
3232
transport: null,
33-
routeHandlerDomain: 'example.com',
33+
routeHandlerModifier: (route) => route.domain('example.com'),
3434
},
3535
})
3636

0 commit comments

Comments
 (0)