# Is it possible to let node-red edit discreted parts of the application?

**URL:** <https://discourse.nodered.org/t/is-it-possible-to-let-node-red-edit-discreted-parts-of-the-application/68539>\
**Category:** General\
**Tags:** function-node\
**Created:** [4 October 2022 10:31 UTC](https://discourse.nodered.org/t/is-it-possible-to-let-node-red-edit-discreted-parts-of-the-application/68539 "2022-10-04T10:31:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![markleo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/markleo/32/68629_2.png) [@markleo](https://discourse.nodered.org/u/markleo)\
**Post date:** [4 October 2022 10:31 UTC](https://discourse.nodered.org/t/is-it-possible-to-let-node-red-edit-discreted-parts-of-the-application/68539/1 "2022-10-04T10:31:31Z")

</div>

I have a express app for providing backend restful API.

`index.js`🙂

```auto
const express = require('express')

const app = express()

// add 
app.get('/hello', (req, res) => {

  // logic steps
  let a = 'hello,'
  let b = 'world!'
  let c = a + b

  res.send(c)
})

app.get('/foo', (req, res) => {

  // logic steps
  let data = handlerFoo(req)

  res.send(c)
})

app.get('/bar', (req, res) => {

  // logic steps
  let data = handlerBar(req)

  res.send(data)
})

function handlerFoo(req) {
  // ... 
}

function handlerBar(req) {
  // .... 
}

app.listen(3000, () => {
  console.log(`Example app listening on port 3000}`)
})

```

is it possible to use `node-red` to edit the handler function? I mean use node-red to write the logic steps for all handlers, the `handlerFoo `, `handlerBar ` implements by `node-RED`.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [4 October 2022 10:54 UTC](https://discourse.nodered.org/t/is-it-possible-to-let-node-red-edit-discreted-parts-of-the-application/68539/2 "2022-10-04T10:54:41Z")

</div>

If you are asking whether Node-RED can host a restful API similar to what you have written in your code, then the answer is yes.

This example in the cookbook shows how to setup an HTTP endpoint in Node-RED: [Create an HTTP Endpoint : Node-RED](https://cookbook.nodered.org/http/create-an-http-endpoint)

---

<div class="post-metadata">

**Author:** ![markleo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/markleo/32/68629_2.png) [@markleo](https://discourse.nodered.org/u/markleo)\
**Post date:** [4 October 2022 13:16 UTC](https://discourse.nodered.org/t/is-it-possible-to-let-node-red-edit-discreted-parts-of-the-application/68539/3 "2022-10-04T13:16:17Z")

</div>

I updated my post, please check it, I only want the node-red to implement one step (function) in a HTTP request-response flow.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [4 October 2022 13:20 UTC](https://discourse.nodered.org/t/is-it-possible-to-let-node-red-edit-discreted-parts-of-the-application/68539/4 "2022-10-04T13:20:43Z")

</div>

You can embed Node-RED into your app as described here: [Embedding into an existing app : Node-RED](https://nodered.org/docs/user-guide/runtime/embedding)

That will allow Node-RED to handle any requests that your own routes don't cover - assuming you have the flow defined in Node-RED to handle the route.

---

<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:** [18 October 2022 13:21 UTC](https://discourse.nodered.org/t/is-it-possible-to-let-node-red-edit-discreted-parts-of-the-application/68539/5 "2022-10-18T13:21:39Z")

</div>

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