Skip to content

Commit

Permalink
Add velocy, a minimal javascript framework (TechEmpower#8403)
Browse files Browse the repository at this point in the history
* add velocy, Node.js framework

* add more info on readme

* bump velocy: 0.0.9 -> 0.0.12

* fixes the dockers issue of lower case naming

* removes the `.vagrant` directory

* Update dockerfile to fix the CI issue.

* add JSON + remove global strings/config
  • Loading branch information
ishtms authored Sep 19, 2023
1 parent 42aecae commit 63b0451
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions frameworks/JavaScript/velocy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
4 changes: 4 additions & 0 deletions frameworks/JavaScript/velocy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Velocy
A minimal high performance web framework for Node.js. The goal and design of Velocy is to be a high performance web framework without installing any dependencies at all! It is a part of an [open source book](https://github.com/ishtms/learn-nodejs-hard-way) that I am writing.

Github repo - [Velocy](https://github.com/ishtms/velocy)
46 changes: 46 additions & 0 deletions frameworks/JavaScript/velocy/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const cluster = require("node:cluster");
const os = require("node:os");
const process = require("node:process");
const { SimpleRouter, createServer } = require("velocy");

if (cluster.isPrimary) {
console.log(`Primary ${process.pid} is running`);

const numCPUs = os.cpus().length;
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}

cluster.on("exit", (worker) => {
console.log(`worker ${worker.process.pid} died`);
process.exit(1);
});
} else {
const router = new SimpleRouter();

router.get("/plaintext", (req, res) => {
let p = "Hello, World!";
res.writeHead(200, {
"content-type": "text/plain",
"content-length": p.length,
Server: "Velocy",
});
res.end(p);
});

router.get("/json", (req, res) => {
let p = JSON.stringify({ message: "Hello, World!" });

res.writeHead(200, {
"content-type": "application/json",
"content-length": p.length,
Server: "Velocy",
});

res.end(p);
});

createServer(router).listen(8080);

console.log(`Worker ${process.pid} started`);
}
26 changes: 26 additions & 0 deletions frameworks/JavaScript/velocy/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"framework": "velocy",
"tests": [
{
"default": {
"plaintext_url": "/plaintext",
"json_url": "/json",
"port": 8080,
"approach": "Realistic",
"classification": "Micro",
"database": "None",
"framework": "velocy",
"language": "JavaScript",
"flavor": "None",
"orm": "None",
"platform": "nodejs",
"webserver": "None",
"os": "Linux",
"database_os": "None",
"display_name": "velocy",
"notes": "",
"versus": "nodejs"
}
}
]
}
14 changes: 14 additions & 0 deletions frameworks/JavaScript/velocy/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[framework]
name = "velocy"

[main]
urls.plaintext = "/plaintext"
approach = "Realistic"
classification = "Micro"
database = "None"
database_os = "None"
os = "Linux"
orm = "None"
platform = "nodejs"
webserver = "None"
versus = "nodejs"
5 changes: 5 additions & 0 deletions frameworks/JavaScript/velocy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"velocy": "0.0.13"
}
}
6 changes: 6 additions & 0 deletions frameworks/JavaScript/velocy/velocy.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:20-slim
WORKDIR /usr/app
COPY ./ /usr/app
RUN npm install
EXPOSE 8080
CMD ["node", "app.js"]

0 comments on commit 63b0451

Please sign in to comment.