diff --git a/lib/bao.ts b/lib/bao.ts index 746d89a..a0053bf 100644 --- a/lib/bao.ts +++ b/lib/bao.ts @@ -104,10 +104,17 @@ export default class Bao { * Start the server on the specified port * * @param options The options for the server + * @param callback The callback function to be run when the server is started * @returns A Bun Server object */ - listen(options: IListen = {}): Server { - return Bun.serve(this.#serve(options)); + listen(options: IListen = {}, callback?: () => void): Server { + const server = Bun.serve(this.#serve(options)); + + if (server && callback) { + callback(); + } + + return server; } #serve(listen: IListen): Serve {