Hi Lughino, doing this as a standard feature is an interesting idea. In a CMS project we often find that since users are cruising in from Google to glance at a page, we don’t necessarily want to “pay the freight” up front to send them a single page application, particularly when Nunjucks renders content server-side as well and as quickly as it does. The startup time isn’t always worth the reduced page transition time.
But there is no reason you can’t easily add REST APIs to any module at project level. Check out the self.route
method of apostrophe-module
(the base class of all modules, so you can mess with it in any module, such as one that extends apostrophe-pieces
). You can also work directly with self.apos.app
to add routes directly via Express if you don’t like the way self.route
prefixes URLs for each module (/modules/module-name/your-route-name
).
In particular, you might consider adding REST APIs to apostrophe-pieces-pages
because it already provides the right convenience methods for fetching pieces on behalf of the general public.