-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boot scripts #2034
Comments
Just an idea about this as a LB user. Hope I am not interfering with your discussion, or that this doesn't go against LB4 principles. Just trying to put my two cents here. I always thought it would be nice to have the option to run your piece of code whenever loopback triggers an event. I imagined it something like:
What I liked about this approach is that:
|
@lucaslopez I like your proposal, but at the same time I feel it's orthogonal to the concept of boot scripts (a convention on where to place source code bits + a booter to discover and execute those bits). Could you please open a new issue where we can focus on discussing your proposal? In LoopBack 3, the application object is also an event-emitter providing events like |
See #1928 |
Is this considered to cover the loopback application to be an event emitter or should I still open a new issue? |
Thanks for the info! I was not aware LB3 is emitting events as well. Is this documented somewhere or it is just meant for internal use? |
Please check out #1928 |
I am running into this issue right no with LB4. I want to make sure certain objects exist in the DB right after starting the application. Since all of the application configuration happens in a Can you help with a workaround with the current state of affairs for LB4? |
@raymondfeng Thanks for your quick answer. I am just using the DB update as an "example" of something you want to happen right after the application starts. It could also be connecting to a server via a socket, validating a bucket exists on S3, or anything really. So #2094 is not really applicable to my question. I did read through #1928 before. I love the approach and would use it if it were available. Unfortunately it is not yet available. So my question is, as I am sitting here today trying to use LB4 to get a project done, what is the best approach to get an asynchronous task done after the application/server starts? |
Hopefully #1928 will be landed soon. Before that, you might have to override |
Thanks! Somehow I was not aware of |
Same here. By default, VS Code is hiding the file for me and I was running under the assumption that TS would be used in all circumstances. |
Please put your custom logic to |
I am closing this story as done via #1928. Please open a new issue if there are any other changes/improvements needed to support your use cases. |
A boot script is a short piece of code that users want to run during application setup (boot), e.g. to apply additional configuration in a programatic way, add more routes, etc.
In LB3, a boot script is a JS file in
server/boot
directory, loopback-boot automatically discovers and runs these scripts as part of boot.For LB4, we should come up with a solution that will enable app developers to define custom code bits to be executed during boot, possibly also during start & stop. It is not necessary to use the LB3 approach, we should approach this challenge with a fresh mind and pick a design that leverages the power of LB4.
Acceptance criteria
TBD
The text was updated successfully, but these errors were encountered: