yonathan06 / fastify-now

File based routing for fastify https://github.com/fastify/fastify
MIT License
72 stars 8 forks source link

Avoid usage of process.cwd() #1

Closed mcollina closed 4 years ago

mcollina commented 4 years ago

The usage of process.cwd() prevents to use this module to package routes in another module. This is common when using lerna (etc).

I would recommend accepting the folder as a parameter.

yonathan06 commented 4 years ago

Thanks! It uses process.cwd() only when no routesFolder parameter is provided. You can see in the example I have in the main readme, that I use path.join(__dirname, './routes') as the routesFolder. Maybe I should remove the default routesFolder parameter and throw an error if non provided.

mcollina commented 4 years ago

I would recommend it. It’s easy to mess up :(, even if it’s a nice dx.

yonathan06 commented 4 years ago

https://github.com/yonathan06/fastify-now/commit/cc6dfc098176eb96b7a3bf78a5d377ac198792d6