Skip to content

Commit

Permalink
feat: pass server object to callback
Browse files Browse the repository at this point in the history
  • Loading branch information
wobsoriano committed Nov 17, 2022
1 parent 88768e7 commit 8d1c0dd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
@@ -1,6 +1,7 @@
import { createRouter } from 'radix3'
import type { RadixRouter } from 'radix3'
import type { Handler, HTTPMethod, ServeOptions } from './types'
import type { Server } from 'bun'

export class Siopao {
router: RadixRouter
Expand Down Expand Up @@ -63,13 +64,13 @@ export class Siopao {
* @param options Bun server options
* @param cb Server callback after server starts listening
*/
serve(options: ServeOptions = {}, cb?: () => void) {
serve(options: ServeOptions = {}, cb?: (server: Server) => void) {
const server = Bun.serve({
...options,
fetch: (request) => this.fetch(request),
})

cb?.()
cb?.(server)

return server
}
Expand Down

0 comments on commit 8d1c0dd

Please sign in to comment.