Wednesday, 15 January 2020

Advice on Approach and Structure

Hi,I'm building my first app in nodejs and I'm hoping for a bit of help on the best approach to take. I'm using this first small project to get a feel for node as I intend on building a number of custom API's for some internal systems so that I can automate tasks.This simple app will allow a user to upload a csv file, this file is then parsed and stored in a database on SQL Server. The file contains about 3000 rows, 10 columns of data in each, and the idea would be that after the file is uploaded it is displayed to the user in table format and validation is carried out on each row of the table. Once every row (and the entire table) is valid and meets the buisness rules the user will be allowed to submit the file for processing to a different Finance system.I read that handlebars was a popular templating engine, so I decided to use that along with express and bootstrap for some quick styling.Where I am getting a bit confused is working out the best approach to get data and send data to the templates. Is it best to build an API that deals with the upload, querying datasets etc. and a completely independent website using ajax to pull in the data or do I just write the logic in a couple of controllers for the different routes and send the data as a json object when rendering the template?If I want to validate the cells on each row of data, what would be the best approach for this? I want the table to be editable so that errors can be corrected and the corrections update to the database.I've got my head around the routing and templating, I got JWT working for authentication and I have multer accepting files and csv-parser working. I just don't think I'm building it like it should be done and I can't seem to find an article that explains the best approach. I've read in a few different places that there should be service files that import the database connection and contain the business logic and that the controller calls these but if that's the case what is the point in the controller.Thanks in advance.

Submitted January 15, 2020 at 11:22PM by aBitOfCloud

No comments:

Post a Comment