3 ms·
I've always favored express.js style routes. Simple, pragmatic, flexible, and run in the order in which they are declared. Internally they are just represented
by iamleppert 10y ago
I've always favored express.js style routes. Simple, pragmatic, flexible, and run in the order in which they are declared. Internally they are just represented as an array of regex's.
For client side routing, I use page (https://www.npmjs.com/package/page https://www.npmjs.com/package/page), which is a tiny client-side router that supports pushState and has an almost identical API as express.
There are lots of people and frameworks who try to overcomplicate this problem when its really just another pattern of inversion of control.
- debbar 10y agoExpress is definitely better than the others. But I still think it has a bloated API that's not strictly necessary. For example, you still have to learn about the gazillion methods on the Response object. Why not simply return a POJO response object: `{ headers: [...], body: '...' }` ? And if it needs to be async, we could return a promise that resolves to a simple response object. This is the first time I'm hearing about `page`. I'll check it out.