krakenjs / swaggerize-routes

Swagger document driven route builder.
Other
58 stars 57 forks source link

prevent to overwrite handlers when handler is created already #85

Open kangchals opened 7 years ago

kangchals commented 7 years ago

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 commented 7 years ago

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~

pmarino90 commented 6 years ago

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