Build REST endpoints with Low-code Backend
Tags: node, javascript, lowcode, showdev
Published: 2022-10-13 17:02:41


Nucleoid low-code framework helps to build REST endpoints with declarative runtime, which manages the control flow and stores in built-in datastore under the same runtime.

Underlying declarative runtime re-renders very same JavaScript codes, makes connections in the graph and eventually saves the JavaScript state so that it doesn't require external database.

## Business Logic

All JavaScript codes are re-rendered and tracked by the runtime with using [abstract semantic graph](https://en.wikipedia.org/wiki/Abstract_semantic_graph) so that the runtime builds up the graph around business logic and in meanwhile the runtime is responsible for technical details.

{% link https://dev.to/nucleoid/low-code-framework-concept-for-nodejs-55b0 %}

## Data

As tracking JavaScript codes, the runtime also saves the JavaScript state as a data storage so that the runtime itself doesn't require any external database. This eliminates a good number of codes as well as complexity of the application. Frankly, it opens up different possibilities. (I'll talk about more in next articles)

---

> :bulb: The main objective of the project is to manage both of data and logic under the same runtime, so that the application can be written with less code lines and without requiring external database.

---

## REST

So far, we have 2 options to integrate with Nucleoid runtime in order to build REST APIs:

### Express.js

```javascript
const nucleoid = require("nucleoidjs"); // npm install nucleoidjs
const app = nucleoid();

class User {
  constructor(name) {
    this.name = name;
  }
}

nucleoid.register(User);

app.post("/users", (req) => {
  const name = req.body.name;
  return new User(name);
});
```

:point_up_2: This is it! It saves your object without external database.

Here is more about complete examples:

{% link https://dev.to/nucleoid/crud-with-nucleoid-low-code-backend-53c5 %}

### OpenAPI

We support OpenAPI 3 with additional `x-nuc-action` field, which takes very similar pure JavaScript codes in Express.js, but it prepares for running with:

> `npx nucleoidjs start`

```json
{
  "openapi": "3.0.3",
  ...
  "/users":{
    "post":{
    "summary":"Create User",
    "request":{
      "type":"object",
      "properties":{
        "name":{
          "type":"string"
        }
      }
    },
    "response":{
      "$ref":"#/components/schemas/User"
    },
    "x-nuc-action":"function action(req) {
      const name = req.body.name;
      return new User(name);"
    }
  }
}
```

[Nucleoid IDE](https://nucleoid.com/ide/) is an online editor that packages :point_up_2: which helps to run with OpenAPI.

<center>
  Give a try at <a href="https://nucleoid.com/ide/">https://nucleoid.com/ide/</a>
<br/>
</center>

![IDE](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4aya1amxp63nxm5rwpbc.png)


![Swagger](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/551nv9y4u5o25hslzycj.png)

## Query

Nucleoid runtime also opens up terminal channel in order to run statements like SQL. This gives the runtime acting like database with pure JavaScript along with simple npm project :sunglasses:


![Query](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gl6gxgrn9cla6pw2fh57.png)

---

Thanks to declarative programming, we have a brand-new approach to data and logic. As we are still discovering what we can do with this powerful programming model, please join us with any types of contribution!

<center>
  Learn more at <a href="https://github.com/NucleoidJS/Nucleoid">https://github.com/NucleoidJS/Nucleoid</a>
</center>

[![Nucleoid Logo](https://cdn.nucleoid.com/media/icon.png)](https://nucleoid.com)