Dual purpose plugin (Node and browser)


#1

I’m working on some code that I want to use in both my aurelia UI project as well as on the server in node.js

The functionality I’m building is a form builder that accepts json as the form definition. I need the code to run on the server to ensure that the form is valid (aurelia-valiation). I’m trying to build out the form builder so that validation can occur completely without the UI. I do rely on Aurelia for dependency injection as well as the event aggregator. Are there any Aurelia libraries that simply won’t work on running as a node project, I’m not doing server side rendering.

I’m assuming doing this as a plugin is the best way.

I’m looking for any tips or suggestions on the best way to achieve something like this. Node is new to me, but on the node end I basically will only be calling one method passing in the json and returning some sort of object that lists out validation results.


#2

Both aurelia DI and EA can run in nodejs env without any problem.

I don’t know about aurelia-validation, as I never used it.

If you want a validation tool works both in backend and frontend just like a function, have a look at my tool, I am in process of writing doc.

https://buttonwoodcx.github.io/doc-bcx-validation


#3

Aurelia-validation does work on node thankfully, the author of that plugin calls that out.


#4

I gave a quick look at your tool. I think I would have been able to use it, but I have too much work done against aurelia-validation to switch


#5

Understand.

Thx for reading it through, obviously it had some impact on you. That is encouraging enough for me :slight_smile:

One more thing I forgot to mention, you don’t need to make your shared lib as a aurelia plugin, since it is not ui related. Be a normal npm package, export some sort of classes, then DI will take care of your lib when it is used inside in an aurelia app.


#6

This tip might be useful to you. Set getter dependencies without using @computedFrom


#7

Unfortunately the project has the UI implementation in it as well currently. I do need to break them apart so that the node end doesn’t need packages like kendo or bootstrap dependencies. The model that these controls get built by should be 100% UI independent. The UI simply displays and updates the model.