Skip to content

Instantly share code, notes, and snippets.

@imalberto
Last active December 19, 2015 16:49
Show Gist options
  • Save imalberto/5986865 to your computer and use it in GitHub Desktop.
Save imalberto/5986865 to your computer and use it in GitHub Desktop.
ac.url* summary to get feedback

objective

========

Mojito is currently rewriting how routes are configured. Routes data is currently shared between server and client runtime.

Mojito will provide a BC layer, if required, in order to minimise inadverse effects on applications.

some background

========

In the next revision of Mojito, the underlying routing mechanism will be changed to be in line with how Express does routing.

This change will have the following effects:

  • routes.json will no longer be the only way routes can be setup, and in fact, it will be reimplemented to be sugar on top of the core implementation.
  • the internal data structure for routes will be affected, and will be in line with more how Express store routes, plus some specific Mojito annotations.
  • routes will no longer be contextualized in the routes.json way. contextualization can still be achieved, but that responsibility now moves to the application layer.
  • deprecation of routes related APIs

WHY ?

Express has already done all the work at the routing later to setup the routes data, and there is absolutely no reason for Mojito to recompute the routes data and store it into a format that is different from Express.

more details

========

  • ResourceStore.getRoutes(ctx) is now deprecated.
    • Routes data are no longer contextualized.
    • The correct way for the application to retrieve routes data is via the mojito instance, which is available on the app instance from Express. e.g. at runtime, req.app.mojito.routes
    • In the future, there might be a sugar accessor to retrieve the routes data, but the master copy will be attached to the req.app.mojito instance.
  • The internal route object structure will be changed to be in line with Express.

is my app affected ?

========

applications making use of the following APIs might be affected:

  • ac.url.make() and ac.url.find() . Indirectly, the underlying implementation is also affected, namely Y.mojito.RouteMaker(). Hopefully applications is accessing routes metadata via the ac.url.* addon.
  • Y.mojito.ResourceStore.getRoutes(ctx)
  • Y.mojito.RouteMaker.make() and Y.mojito.RouteMaker.find()
Search for the following to find out if the app is affected:

- ac.url.*
    - make()
    - find()
- RouteMaker
    - getComputedRoutes()
    - make()
    - find()
- ResourceStore
    - getRoutes(ctx)


// e.g. in mojito-shaker
addons/ac/shaker.server.js
29:            data.route = ac.url.find(adapter.req.url, adapter.req.method);


the ask

========

Ideally, Mojito would like to start with a clean slate and use the new route structure for sharing routes data between server and client runtime.

We would like to get more details as to how Search app:

  • is affected by the above API changes, and if so
  • how is the app using the routes data to access properties like path, call, etc etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment