# Node Github template

**URL:** <https://discourse.nodered.org/t/node-github-template/45799>\
**Category:** Developing Nodes\
**Created:** [17 May 2021 19:02 UTC](https://discourse.nodered.org/t/node-github-template/45799 "2021-05-17T19:02:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nlecaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nlecaude/32/25_2.png) [@nlecaude](https://discourse.nodered.org/u/nlecaude)\
**Post date:** [17 May 2021 19:02 UTC](https://discourse.nodered.org/t/node-github-template/45799/1 "2021-05-17T19:02:37Z")

</div>

Hello,  
I created a template repo on Github you can use to quickly start a new node:

> **[natcl/node-red-contrib-placeholder](https://github.com/natcl/node-red-contrib-placeholder)**
>
> Contribute to natcl/node-red-contrib-placeholder development by creating an account on GitHub.

It's not fancy or anything but could be useful, it integrates a sample test too.  
Let me know what you think !

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 May 2021 19:32 UTC](https://discourse.nodered.org/t/node-github-template/45799/2 "2021-05-17T19:32:00Z")

</div>

Hi Nathanaël,

Must admin that I like more structure to my packages. I always put my nodes into a `nodes` folder. It is true that uibuilder is a little on the extreme side but this is the top-level structure for it:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bdd5e02fea898129e3c3e3de18ef69fafe888f40.png)

`node_modules` wouldn't be in git of course. And `templates` and `front-end` are quite specific to uibuilder. You might not want the typedefs and `.d.ts` files either. But I usually end up with bin, docs, examples, nodes, tests. I always include a README.md, a LICENSE, generally a CHANGELOG.md and sometimes a TODO.md file.

I also prefer a more strongly structured .js file with at least sections for overall setup, a `nodeInstance` function that is consumed by the `registerType` (I always use the same function name rather than calling it after the node since I find that unnecessarily specific and distracting). `nodeInstance` will contain a `nodeInputHandler` function that is consumed as `node.on('input', nodeInputHandler)` and also a `node.on('close', function(removed,done) {...}` so that I don't forget it if I need it.

I also find it helpful to have a configuration node in my standard template because I can never remember how to do that without lots of reading 🙂

My html file uses the newer `<script type="text/html" data-template-name="uibuilder">` and `<script type="text/html" data-help-name="uibuilder">` sections rather than using `text/x-red` which editors really don't like. Also, my front-end javascript is wrapped in an IIFE because lack of that really caused me some VERY hard to track down bugs in the past.

```auto
;(function () {
    // all the code - a leading ; because I don't use trailing ;s all over the place
})()

```

I also make use of extensive 'regions' comments along with lots of JSDoc to help eliminate the silly mistakes I'm prone to making. Regions let you fold up arbitrary areas of code in the better code editors.

---

<div class="post-metadata">

**Author:** ![nlecaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nlecaude/32/25_2.png) [@nlecaude](https://discourse.nodered.org/u/nlecaude)\
**Post date:** [17 May 2021 19:46 UTC](https://discourse.nodered.org/t/node-github-template/45799/3 "2021-05-17T19:46:06Z")

</div>

Thanks ! I'll update it with some of your suggestions.  
I wanted to keep my template simple as I usually add more folders if the node gets more complex over time.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 May 2021 19:48 UTC](https://discourse.nodered.org/t/node-github-template/45799/4 "2021-05-17T19:48:39Z")

</div>

Certainly nobody ever called my code or designs "simple" 😀

I decided that I don't like thinking about things if I don't have to and so I'd rather start with everything in place up front. I can always delete if things get too messy but honestly, I nearly always end up with everything anyway.

---

<div class="post-metadata">

**Author:** ![Nathanli](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@Nathanli](https://discourse.nodered.org/u/Nathanli)\
**Post date:** [18 May 2021 03:15 UTC](https://discourse.nodered.org/t/node-github-template/45799/5 "2021-05-18T03:15:28Z")

</div>

Thanks for sharing

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 July 2021 03:15 UTC](https://discourse.nodered.org/t/node-github-template/45799/6 "2021-07-17T03:15:29Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
