Configurable catchall on xrpc-server ()

* allow configurable catchall on xrpc-server

* changeset
This commit is contained in:
Daniel Holmgren 2024-04-04 17:58:16 -05:00 committed by GitHub
parent 115df69574
commit cd4fcc709f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions
.changeset
packages/xrpc-server/src

@ -0,0 +1,5 @@
---
'@atproto/xrpc-server': patch
---
Add configurable catchall

@ -72,7 +72,10 @@ export class Server {
this.addLexicons(lexicons)
}
this.router.use(this.routes)
this.router.use('/xrpc/:methodId', this.catchall.bind(this))
this.router.use(
'/xrpc/:methodId',
opts?.catchall ?? this.catchall.bind(this),
)
this.router.use(errorMiddleware)
this.router.once('mount', (app: Application) => {
this.enableStreamingOnListen(app)

@ -8,8 +8,15 @@ import {
ResponseTypeNames,
} from '@atproto/xrpc'
export type CatchallHandler = (
req: express.Request,
_res: express.Response,
next: express.NextFunction,
) => unknown
export type Options = {
validateResponse?: boolean
catchall?: CatchallHandler
payload?: {
jsonLimit?: number
blobLimit?: number