Micro router for workers

Hey there

I created this super simple micro router for my API on workers.

Still not production ready (it will be) but it’s a good starting point or example for making your own router if my style of code doesn’t suit your taste. It has route parameters which the official router template doesn’t have. I’ll be implementing optional parameters too in a couple of days.

It doesn’t use regex on purpose to make it even faster since those 50ms are super precious.

Routes are not initialized on each request since I assume this is more efficient as CF keep workers warm for a period of time.

Anyway, hope this might be useful to someone. This is such a small thing that it doesn’t make sense to put it on NPM.

3 Likes

Thanks for sharing!

For those looking for production-ready router for workers, there’s also:

1 Like