Vivae.js
- 2 Devlogs
- 20 Total hours
Dependency-free HTTP framework for Node.js and serverless runtimes.
Dependency-free HTTP framework for Node.js and serverless runtimes.
This update mostly includes optimization and changing how things work internally. 3 days ago I saw in my code I was storing a large object in memory just to return it as soon as it was created, it was an easy fix but saves a lot of memory. The next major change was moving my v.next() function into a parameter that could be directly used in middleware.
Before:
app.use((v) => {
return v.next()
})
After:
app.use((v, next) => {
return next()
})
This might seem like nothing but this allows you to write more after the middleware finishes so it is now possible to run code after the next middleware is ran. I also realized I should’ve done this earlier because it gives my framework a better structural advantage so I am able to add more routers which is exactly what I am working on now.
Last year I wanted to make a lightweight version of Express (Node.js based) but now I decided I wanted to take my framework more seriously and make it have better portability, so I switched my web framework’s middleware to use web standard instead.
This is how using my framework is like currently
import vivae from "@vivaejs/server";
const app = vivae();
const port = 3000;
app.use("/", ["GET", "POST"], (v) => {
return v.send("Hello World!");
});
Depending on if your using Node.js or Edge runtimes you would put this at the bottom:
// Node.js
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});
// Edge
export default {
fetch: app.fetch,
};
Also I’ve released the first alpha version of my package on npm so it can be installed like this!
npm install @vivaejs/server@0.1.0-alpha.0
I have an API references in my documentation for more information about all the features, majority of this was spent converting my project to web standard instead of Node.js.