@@ -252,4 +252,56 @@ The router will handle loading the HTML, running the initializer function, and c
252252
2532536 . ** Clean Up Event Listeners** : If your initializer adds event listeners, make sure to remove them when the page is unloaded to prevent memory leaks.
254254
255- 7 . ** Test Thoroughly** : Test your new route with different scenarios (logged in, logged out, with/without subscription) to ensure it behaves correctly.
255+ 7 . ** Test Thoroughly** : Test your new route with different scenarios (logged in, logged out, with/without subscription) to ensure it behaves correctly.
256+
257+ ## Using the Route Generator Script
258+
259+ For faster development, you can use the provided route generator script to automatically create all the necessary files and code for a new route.
260+
261+ ### Prerequisites
262+
263+ Make sure the script is executable:
264+
265+ ``` bash
266+ chmod +x bin/generator.js
267+ ```
268+
269+ ### Usage
270+
271+ ``` bash
272+ ./bin/generator.js --route=" /my-feature" --name=" My Feature" [--auth] [--subscription]
273+ ```
274+
275+ ### Options
276+
277+ - ` --route ` : The route path (required, e.g., "/my-feature")
278+ - ` --name ` : The feature name (required, e.g., "My Feature")
279+ - ` --auth ` : Add this flag if the route requires authentication
280+ - ` --subscription ` : Add this flag if the route requires an active subscription
281+ - ` --help ` : Show help information
282+
283+ ### Example
284+
285+ ``` bash
286+ ./bin/generator.js --route=" /contact-us" --name=" Contact Us"
287+ ```
288+
289+ This will:
290+
291+ 1 . Create a new HTML view file at ` public/views/contact-us.html `
292+ 2 . Add an initializer function ` initContactUsPage ` to ` public/js/page-initializers.js `
293+ 3 . Add the route to ` public/js/router.js `
294+
295+ For a protected route that requires authentication:
296+
297+ ``` bash
298+ ./bin/generator.js --route=" /dashboard" --name=" Dashboard" --auth
299+ ```
300+
301+ For a premium route that requires a subscription:
302+
303+ ``` bash
304+ ./bin/generator.js --route=" /premium-feature" --name=" Premium Feature" --auth --subscription
305+ ```
306+
307+ After running the generator, you can customize the generated files to fit your specific requirements.
0 commit comments