In this Boring Stack release, the create-sails-generator
simplifies creating pages for your SPAs along with their actions.
Previously, to add a new page to your SPA, you had to manually create the component file in assets/js/pages/
and then create the corresponding action to serve the page in api/controllers/
.
Not only that, you’d have to change the responseType
of your success
exit signal to inertia
and then return the page within the return object. And of course, you’d have to specify the route in config/routes.js
.
Sounds like a lot, right? Oh yeah, that’s because it is!
With create-sails-generator
, all of the above processes are now streamlined into a single sails generate page <page-name>
command.
The command will detect the UI framework you are using (Vue, React, Svelte) and generate the corresponding component file accordingly.
It will also generate the accompanying action to serve the page, leaving you with the only task of specifying the route in config/routes.js
.
Simplified Custom Responses Update
Since transitioning to custom responses in Boring Stack v0.2.0, one thing I’ve been thinking about is how to evolve the responses without requiring users to copy and paste them when updates are made.
To simplify managing evolving custom responses in The Boring Stack, create-sails-generator
now provides generators for copying custom responses with generator commands. Check them out below:
inertia custom response
sails generate inertia
inertia-redirect custom response
sails generate inertia-redirect
bad-request custom response
sails generate bad-request
See the full changelog on GitHub.
✅ Upgrading
To upgrade to 0.2.2, do the following:
Install the latest version of create-sails-geneator as a dev dependency
npm i create-sails-generator@latest -D
Update .sailsrc
Update your .sailsrc
generator config with the below config in "modules" : {}
:
"modules": {
"page": "create-sails-generator/generators/page",
"inertia": "create-sails-generator/generators/inertia",
"inertia-redirect": "create-sails-generator/generators/inertia-redirect",
"bad-request": "create-sails-generator/generators/bad-request"
}
You can now create pages by running sails generate page example/page
.
Be sure to replace
example/page
with the exact name of the page you want to create
P.S: If you haven’t starred the project yet, please I’d appreciate if you give it a star ⭐️ on GitHub.