swaggerize-routes
swaggerize-routes copied to clipboard
prevent to overwrite handlers when handler is created already
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!
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~
Hi, I arrived at the same issue when using pkg. I fixed with Object.assign too. Is there any issue for keeping this open?