New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
examples: Externalize configuration values and allow for multiple env… #28
Conversation
…ironments In order to more easily manage testing of various order types as well as production, development etc. environments, externalize this config values. Signed-off-by: Herman van Hazendonk <github.com@herrie.org>
@nanov Happy to receive feedback on how to do things differently. I'm not a very experienced NodeJS developer, so I can see this work and did it based on some "best practice" examples I could find. But open for improvements. Just I'm running Test and Production in parallel and found that it was a bit cumbersome to run the examples the way they were structured currently, hence this PR. You would basically run the scripts like "node bankLetter.js testing" or "node bankLetter.js production" and it would pick up the correct values for the testing or production server and fallback to testing in case there's an invalid value. |
Hey @Herrie82, again thank you for your devoted work! In this case I would structure things a little bit differently and certainly won't add another dependency ( lodash in this case ). I hope i can find the time during the weekend to structure your ideas, which are absolutely in the right direction, into some reusable code. |
@nanov Yeah I wasn't too happy with the dependency as well. Happy to see what you come up with. As usual there are multiple ways to solve a problem. Mine is one, I'm sure you probably have an even more elegant one ;) Will be using it shortly in a production system, so trying to contribute some of the things I use and things I ran into to be not very efficient while testing. All little bits always help is my experience, to make it easier for others down the line. |
Well, there are also some personal style preferences and experience involved. At the end of the day working solution is what one is after and yours is one!
We are using this library in production with almost zero issues for a while now. I would do my best to do some more real-world examples over the weekend ( or next week ), as I truly believe it would be useful! |
@nanov Had any chance to look into this? We're about to deploy into production shortly, so it would be good if we can use your version directly ;) |
Hi, sorry for the late response, I've been crazy busy these days. I''l do my best to commit something ASAP. |
@nanov I know the feeling, don't worry. Looking forward to see your solution! |
@nanov I saw you merged it, but didn't change anything by the looks of it (yet)? Do you plan to make changes still? Just curious. I might be using this now for multiple banks going forward, since it seems to be working well. So I might propose some more changes to be able to deal with that as well in terms of config. |
@Herrie82 finally found the time to make the changes yes, making them right now, will commit and release later on today! |
@nanov Ah great. I assume that when using multiple banks we'd need to have separate files to save the keys for each bank? Didn't give much thought about it yet, but since you're making changes you might have some thoughts on that as well and do it in 1 go. |
Well, how to implement your full architecture is up to you, I'm trying to structure some basic example to get people going. I could give you some insights on how we operate with mulitple banks, we have a DB record for each ebics acocunt ( ie bank ), and a directory structure so one would know where to look for traces keys and etc. Also this record contains some settings regarding the account ( STA or C53, special adapters for the data if needed and so on ). We execute operations based on the account ( for example /accounts/my-cool-ebics-account/downloadDailyStatement/ ), then based on the account config ( from db ) we do the desired operation and process it's results. |
@nanov OK doesn't sound too distant from what I have for processing individual bank account. Just don't have the whole connectivity bits integrated in our SQLite DB (yet). We have separate scripts for separate channels (FTP, EBICS etc). Good to get your thoughts on that. |
could you take a look and test the changes? |
@nanov Ooh nice cleanup again :) I'll give it a go probably tomorrow or Friday. A bit hectic these days. |
@nanov Sorry for the delay, finally got to test this now. I seem to get the following error. I'm not very familiar with the way you coded it, so just posting it here for guidance: `C:\node_modules\ebics-client2\examples>node send-vmk-order.js production TypeError: loadConfig is not a function |
my bad, should be fixed right now |
@nanov better but still not working: C:\node_modules\ebics-client2\examples>node send-vmk-order.js production Error: EBICS URL is required |
just change the 'serverAddress' in the config file to 'url' |
To be clear, this is just an example how one may build multi config cli with the library |
@nanov Nope that doesn't work :S Loading config form C:\node_modules\ebics-client2\examples\config with env set to production. Error: EBICS URL is required Config file:
|
now? :) |
@nanov Getting closer and closer: client.send(ebics.Orders.VMK(null, null)) // startDate 'YYYY-MM-DD', endDate 'YYYY-MM-DD' ReferenceError: ebics is not defined When I manually add:
|
have you provided keys? ** EDIT ** keyStorage path should be absolute path, or relative to cwd ( ie where you run node ) EDIT 2 Now i saw and fixed the name of the property ( keyStorage -> keyStoragePath ) |
@nanov Yeah I have the "keys-prod"-file in the config directory and in the examples one. |
See my edits |
@nanov Yes just leaves the "client.send(ebics.Orders.VMK(null, null)) // startDate 'YYYY-MM-DD', endDate 'YYYY-MM-DD' ReferenceError: ebics is not defined" |
i'll add those to all examples now, thank you! |
Could you check it out now? |
@nanov Yes that seems to work now, thanks :) |
@Herrie82, could you share your case in more detail, i mean as needs and uses so we( together with you) could that building an ecosystem upon it |
@nanov for now it's pretty straight forward for EBICS for now. 1 bank, just collecting STA and VMK on scheduled intervals. We run this on a Windows server with simple task scheduler. Works fine in general. The files get saved to a network share (I added this value for network location to the config file) and simply added writing of the STA/VMK orders to the example files. From there we feed it (together with files which we got from various other banks via good old S(FTP)) into some custom scripts (VBScript, very old (2008-2012 era), but work very reliably) which has a SQLite DB in the back-end with all our accounts, entity info, daily statements expected etc, so it can verify that for all accounts we have received statements, how many etc. Any special actions that need to be performed on the statements (i.e. account number replacements or some regexp for processing) all happen there. As output we have a concatenated file per account with all statements for that account. Which we then consolidate into a single file per entity which we send to our accounting and TMS system. The VBScript also produces some email report about the processing so that we know right away the status in the morning. In case of new accounts these would be added to the DB automatically as well based on found files and would be listed in the email as well, so we know there are new accounts which need "setup" in the database. |
@nanov We recently got our 2nd bank connection (Credit Suisse), which was on the tested bank list already. Went smoothly. Just wondering how to structure the config files to allow for multiple banks. Any thoughts? A question occurred in terms of the bank-keys file. Can you use a single file for multiple banks or you would need to have a single keys file per bank? |
@Herrie82 sorry for the late response!
Our setup is something like this:
and so on, as for config you'll have to find a solution that works for you ( loads the right config according to parameter for example ), one option is to do a config format as following : |
…ironments
In order to more easily manage testing of various order types as well as production, development etc. environments, externalize this config values.
Signed-off-by: Herman van Hazendonk github.com@herrie.org