This is a bundle that integrates nicely with express within the framework.
HTTPBundle starts the
listen() in the
KernelAfterInit hook. So the application starts listening before
kernel.init() promise resolves. If there's an error with starting the server like the port is already in use, the
kernel.init() will fail.
The most typical thing you would do is add middlewares and routes. You have access to the
express.Application directly from the bundle, and an easy way to just add routes:
A good idea is to separate your routes:
Handlers can be chainable:
Now you can better add them without poluting bundle code:
You have two specialized events at your disposal:
HTTPBundle finishes preparation you already have an
app property which the express instance: