# \[NEW NODE\] node-red-contrib-primitive-status

**URL:** <https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643>\
**Category:** Share Your Nodes\
**Created:** [24 October 2021 04:48 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643 "2021-10-24T04:48:28Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [24 October 2021 04:48 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/1 "2021-10-24T04:48:28Z")

</div>

I have released version **1.0.0** of the _node-red-contrib-primitive-status_ node.

A Node-RED node that displays the primitive type of `msg.payload` in the nodes status. Messages will pass through the first output, and the primitive type is returned as a string from the second output.  
The node requires no configuration.

> **[GitHub - HaroldPetersInskipp/node-red-contrib-primitive-status: Node-RED node...](https://github.com/HaroldPetersInskipp/node-red-contrib-primitive-status)**
>
> Node-RED node that displays the primitive type of msg.payload in the nodes status. - GitHub - HaroldPetersInskipp/node-red-contrib-primitive-status: Node-RED node that displays the primitive type o...

This is my second node published, please critique it, I'm new to coding and want to get better.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [24 October 2021 08:46 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/2 "2021-10-24T08:46:23Z")

</div>

Maybe add (optional?) msg.type to output 1?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 October 2021 08:49 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/3 "2021-10-24T08:49:58Z")

</div>

As it is passed to the status already it could be caught by a Status node - so is the second output even needed ?

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [24 October 2021 09:12 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/4 "2021-10-24T09:12:21Z")

</div>

I wanted to leave the message on output one alone as a pass-through for debugging, and not altering the message. And to have the second port for additionally instructing the flow based on type, or counting/classifying types of messages.

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [24 October 2021 09:19 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/5 "2021-10-24T09:19:10Z")

</div>

Status node? I'm not sure I follow what you are saying, could you elaborate?

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [24 October 2021 09:24 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/6 "2021-10-24T09:24:08Z")

</div>

Actually, I get what you mean now.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 October 2021 09:27 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/7 "2021-10-24T09:27:07Z")

</div>

Hi, at first I thought what is the point of this node but from a low code point of view it's not actually a bad idea.

Personally, I would have just one output and add the type to a `msg` property. E.g. `msg.propertyType`

That way, you could have a switch node after your node that permits routing of the message based on type.

Also, I'd permit the user to test more than just `msg.payload` (e.g. the user might want to route messages where `msg.res` is an object)

Lastly, I'd be inclined to test further than primitive type. E.g a buffer, an array & many other well-known prototypes are described as an "object". However you could test the object with `Array.isArray` and `Buffer.isBuffer` etc.

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [24 October 2021 09:32 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/8 "2021-10-24T09:32:38Z")

</div>

I do want it to be able to test more than just `msg.payload`. (I'm kind of new to coding so this may take a bit to figure out).

It can handle array, but I should add buffer as well (despite the node name). And thank you, I really appreciate the input.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 October 2021 10:33 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/9 "2021-10-24T10:33:39Z")

</div>

> [@Steve-Mcl](#):
>
> That way, you could have a switch node after your node that permits routing of the message based on type.

Can't you do that already with the `isOfType` test in the Switch node?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 October 2021 10:38 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/10 "2021-10-24T10:38:33Z")

</div>

True. But then you'd still not see the type name on the status without adding a function node. I was only suggesting how I'd approach it to make it a bit more useful (low code being the focus) tbf Colin. Personally, I'd just use `typeof` and `node.status` in a function but I can see some benefit for those not so clued up.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [24 October 2021 12:02 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/11 "2021-10-24T12:02:02Z")

</div>

At first, this approach seems a good one 🙂 ...... but ......

It's much easier to do stuff further down the flow if the message itself is carrying ALL the information

If you make it optional, then everyone is happy 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [24 October 2021 12:35 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/12 "2021-10-24T12:35:39Z")

</div>

... but if all you need it for down the flow is for a switch then just use a switch... and if the switch node doesn't have the correct options for type then maybe that should/could be enhanced...  
If you just want it to be visible then it's fine as-is

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [24 October 2021 14:51 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/13 "2021-10-24T14:51:40Z")

</div>

Adding `msg.type` to first output is supported as of version 1.0.2

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [24 October 2021 14:56 UTC](https://discourse.nodered.org/t/new-node-node-red-contrib-primitive-status/52643/14 "2021-10-24T14:56:43Z")

</div>

🙂

So next, maybe let user change what it's called (in case msg.type is used by another node in the same flow)

Just suggesting these things as a way to develop your node creation skills 🙂
