baojs
baojs copied to clipboard
app.listen() callback?
Do we have such a thing?
I've seen this thing before. I would like to contribute.
Do we have such a thing?
I'm unsure if this is needed, once app.listen()
is executed, it will return a Server object and the code below it will continue to execute, e.g.
const server = app.listen();
console.log(server.hostname); // http://0.0.0.0:3000/
I might be wrong though - let me know if I've missed something!
Adding a callback like feature would be easy as this:
class Bao {
listen(options: IListen = {}, cb?: () => void): Server {
const server = Bun.serve(this.#serve(options));
cb?.()
return server
}
}
Adding a callback like feature would be easy as this:
class Bao { listen(options: IListen = {}, cb?: () => void): Server { const server = Bun.serve(this.#serve(options)); cb?.() return server } }
we can merge my pr actually for this.
@fdemir Oh I did not notice 😅 awesome!