swaggerize-routes icon indicating copy to clipboard operation
swaggerize-routes copied to clipboard

prevent to overwrite handlers when handler is created already

Open kangchals opened this issue 7 years ago • 2 comments

A result of fs.readdirSync(dir) is important because it could create error when the order of directory name precede filename.

for example, let's assume that there is two files. handlers/users.js handlers/users/{userId}.js Normally the result of fs.readdirSync(dir) will be ['users.js', 'users']. it works fine. However, when the result of fs.readdirSync(dir) is [ 'users', 'users.js']. it makes error. it will overwrite users.js's handler.

I faced this situation when I tried to use pkg(https://github.com/zeit/pkg) for my project using swaggerize-hapi

I read the api document for fs.readdirSync, I cannot found the order of the result fixed.

I think the code requesting pull request prevent that kind of possible error situation.

Thanks!

kangchals avatar Jul 13 '17 01:07 kangchals

Object.assign is not supported the node version is below than 4.....

I found ponyfill for the Object.assign 'https://www.npmjs.com/package/object-assign'

Do you want to apply the ponyfill and pull request again?

Let me know~

kangchals avatar Jul 13 '17 02:07 kangchals

Hi, I arrived at the same issue when using pkg. I fixed with Object.assign too. Is there any issue for keeping this open?

pmarino90 avatar Oct 23 '17 22:10 pmarino90