Skip to content

Adding configuration file, starting with dynamic error codes and messages#25

Merged
jcoupey merged 4 commits intoVROOM-Project:masterfrom
GIScience:master
Apr 26, 2019
Merged

Adding configuration file, starting with dynamic error codes and messages#25
jcoupey merged 4 commits intoVROOM-Project:masterfrom
GIScience:master

Conversation

@TimMcCauley
Copy link
Copy Markdown
Collaborator

Providing the ability for users to dynamically use their own error codes which are able to consume custom messages. Happy to discuss and improve.

@jcoupey
Copy link
Copy Markdown
Contributor

jcoupey commented Apr 16, 2019

Thanks for submitting!

I'm 100% in favour of improving the error messages by providing more details the way you did. I'm not sure I totally get the error code part though, as it is already possible to adjust the default values (currently in errorCode). Do you have a use-case where this is too limiting?

@TimMcCauley
Copy link
Copy Markdown
Collaborator Author

Hi @jcoupey - the objective would be to outsource all config information into the config.js file that noone has to edit the corresponding parts in the actual API code, e.g.

  • Routing servers
  • Config data

I think it makes it a little cleaner and easier to understand in my opinion. The templates now used for error codes are just a first prototype and I think there might be a cleaner way to do this than initiating the config class again and again. What do you think?

@jcoupey
Copy link
Copy Markdown
Contributor

jcoupey commented Apr 18, 2019

outsource all config information into the config.js file that noone has to edit the corresponding parts in the actual API code

Agreed, that would be a good improvement. Recreating the objects dynamically is indeed probably not the most efficient way. Maybe we could simply have "global" variables living in config.js and expose them via module.exports for use in index.js?

What about getting started with:

  • moving routingServers to config.js
  • moving errorCode to config.js
  • moving command-line args to config.js
  • porting your improved error messages directly back in index.js

The rationale for the last one would be that having the relevant message directly generated in the request treatment context might make the whole logic more clear. And hopefully having better messages might also remove the need for customization. ;-)

@jcoupey
Copy link
Copy Markdown
Contributor

jcoupey commented Apr 18, 2019

On a technical level, there are some code syntax changes (and a couple dependency updates), so it looks like you've been using some kind of linting tool.

Making this part of the workflow at the project level at some point would be another valuable addition. On the other hand, for the readability of the diffs in this PR, we should probably handle that (before or after) in a dedicated PR.

@TimMcCauley
Copy link
Copy Markdown
Collaborator Author

@jcoupey I refactored towards your suggestions - what do you think? Regarding the linter, I am using https://github.com/jonlabelle/SublimeJsPrettier which uses prettier under the hood.

@jcoupey
Copy link
Copy Markdown
Contributor

jcoupey commented Apr 26, 2019

@TimMcCauley thanks for the refactor! I'll take time for a review.

In order to keep the diff focused on the changes you're making, I reverted the parts that are only syntax-related. I also opened #26 to track linting changes, but I'd like to apply them all at once later (with no functional change).

Comment thread src/config.js Outdated
Comment thread src/config.js Outdated
Comment thread src/index.js Outdated
Comment thread src/index.js Outdated
@jcoupey jcoupey added this to the v0.5.0 milestone Apr 26, 2019
@jcoupey jcoupey merged commit e85565e into VROOM-Project:master Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants