× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



" Further, in Node.js there is a practice of creating an index.js in each
...."

Odd you should say that because I have not come across that anywhere that I
can remember. I am currently working on contact in a node.js devops shop
(no IBMi in sight) and there are dozens of apps (all different repos) and
none have that structure. The observation that you can pretty much do what
you like is true, and if you pick a framework that has an opinion (like
Sails) on structure then it is usually fairly obvious.

One thing I will say, get used to writing your code in Typescript (not
JavaScript/node). You won't regret it, and you can make use of the very
latest language updates even if your node.js version doesn't support them
yet.

-----Original Message-----
From: OpenSource [mailto:opensource-bounces@xxxxxxxxxxxx] On Behalf Of Aaron
Bartell
Sent: 11 January 2018 21:37
To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxx>
Subject: Re: [IBMiOSS] Node code organization

Node.js is a little odd (opinion). For example, I find that apps will
sometimes put the core of the business application in a folder named 'lib'.
In RubyOnRails I would consider the lib folder to hold Ruby extensions and
such, nothing to do with the actual business app (model, view, controller).

Further, within the lib/ folder is the domain folder (i.e. customer) and
within there is the route.js, handler.js, helper.js, model.js, etc. Again,
this is different from my RubyOnRails upbringing where, as Pete pointed out,
you'd delineate by directories first (i.e. all models go in the models/
directory).

Further, in Node.js there is a practice of creating an index.js in each
directory which, when imported, will appropriate load or do other things for
the remaining files in that directory.

On final note, this is one reason I like RubyOnRails. They picked a folder
structure that worked for 99% of web apps and sent people down that path.

Aaron Bartell
IBM i hosting, starting at $157/month. litmis.com/spaces


On Thu, Jan 11, 2018 at 1:42 PM, Pete Helgren <pete@xxxxxxxxxx> wrote:

Some frameworks are opinionated and some aren't so it depends if you
are going to end up fighting conventions or not. I think just about
any framework with an MVC design pattern will group like code/objects
together and I even do that for my RPG stuff (which has no opinion).
Node itself I don't think cares about structure. It is what ever is
familiar to you, but in most cases my guess is that you'll follow
either a logical grouping of like code:

/Model

/View

/Controller

Or use a naming convention: model1.js, view1.js, controller1.js under
a single folder. My Java and Rails projects follow the convention
above; A structured, opinionated layout. My Node projects follow the
latter unless they use a framework that has it's own opinionated
structure.

I'd say with complex apps, MVC by folder groupings may be easier. For
small apps I'd keep it simple....

Pete Helgren
www.petesworkshop.com
GIAC Secure Software Programmer-Java
Twitter - Sys_i_Geek IBM_i_Geek


On 1/11/2018 12:20 PM, Justin Taylor wrote:

Are there standards for how Node code should be organized? I
scaffold'd an Express app for R&D, and it gave me a dir structure.
I'm just not sure where my various bits of code should go.

Thanks


--
This is the IBMi Open Source Roundtable (OpenSource) mailing list To
post a message email: OpenSource@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
https://archive.midrange.com/opensource.

--
This is the IBMi Open Source Roundtable (OpenSource) mailing list To post a
message email: OpenSource@xxxxxxxxxxxx To subscribe, unsubscribe, or change
list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at https://archive.midrange.com/opensource.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.