GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing nullstack.app — Script Runner - Nullstack Script RunnerThe context is a simple javascript object that is completely decoupled from the framework itself and can be taken advantage of to use the same context as the main application to run scripts. After compilation you can access it's keys running a script in another file that simply imports the environment bundle. This pattern is much more convenient than having to duplicate your logic for one-off scripts. You must manually start the application to make sure that the context is populated. You must exit the process manually unless you want to have a script that is continuously alive. The example bellow is a simple JavaScript file under scripts/seed.js used for seeding the MongoDB database registered in the context:
To run it you can simply execute it as a normal node command.
Script runners are great for many things like:
Note that you are not limited to the above, you can be creative and use it for more complex things like watching blockchain events or task needs access to the same context as your application. Next Step➡️ Learn more about Advanced concepts: How to customize Webpack❓ Have any questions or suggestions? Join our Discord |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |