This content originally appeared on DEV Community and was authored by Can Mingir
What is the state-based data storage?
The state-based data storage runs as a runtime that is embedded inside Node.js and as writing just any other codes in Node.js, it rerenders the same JavaScript codes and makes the necessary adjustments in the state as well as stores on the disk, so that your application doesn't require external database.
...but why? 🤔
Even simple applications today require lots of coding, libraries, tuning etc., and majority of them are technical codes rather than business logic. Declarative runtimes like Nucleoid can organically reduce numbers of code lines needed.
Installing
Once you include in your project, this is pretty much it!
npm install nucleoidjs
here is the hello world:
const nucleoid = require("nucleoidjs");
const app = nucleoid();
class User{}
nucleoid.register(User);
app.post("/users", () => new User());
app.listen(3000);
💾 Just a quick reminder, it doesn't require external database in order to save the object.
Let's add a little bit coloring with CRUD:
// Create
app.post("/users", (req) => new User(req.body.name));
// Read
app.get("/users/:id", (req) => User[req.params.id]);
// Update
app.post("/users/:id", (req) => {
let user = User[req.params.id];
if (user) {
user.name = req.body.name;
return user;
}
});
// Delete
app.delete("/users/:id", (req) => delete User[req.params.id]);
As you may realize, it comes with Express.js, you can also reach out original Express.js APIs:
const nucleoid = require("nucleoidjs");
const app = nucleoid();
...
const express = app.express();
express.get("/test", (req, res) => res.send("Hello!"));
Star us for the support https://github.com/NucleoidJS/Nucleoid
This content originally appeared on DEV Community and was authored by Can Mingir

Can Mingir | Sciencx (2022-01-21T14:25:19+00:00) Nucleoid: State-based data storage with Vanilla JS. Retrieved from https://www.scien.cx/2022/01/21/nucleoid-state-based-data-storage-with-vanilla-js/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.