cds-snc / node-starter-app

Quick start application setup.... because you have to start somewhere.
MIT License
5 stars 3 forks source link

Localized URLs via routing #92

Closed jneen closed 4 years ago

jneen commented 4 years ago

This PR introduces localized URLs, such as /en/start or /fr/debut

Fixes #58.

We introduce a new method to routes, .draw(app), which returns a DrawRoutes object. This object has methods .get(...), .post(...), .put(...) and .delete(...), as well as a generic .request(methodName, ...) to register paths to the app object. Notably, these methods do not receive a path parameter - instead, we will draw paths for all locales, using the path names in config/routes.config.js. We also insert a middleware which sets the locale, so the correct locale is available within the handler and all subsequent middleware.

BREAKING: route.path now returns an object, such as { en: '/en/personal', fr: '/fr/personnel' }. This will likely break code that relies on route.path being a string.

lgtm-com[bot] commented 4 years ago

This pull request introduces 1 alert when merging 4857db362ed385e414aef2d1150819c3a3f735e6 into 918f143cb43acc63ade70c48a6b3750c6ae18184 - view on LGTM.com

new alerts: