forked from TechEmpower/FrameworkBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add velocy, a minimal javascript framework (TechEmpower#8403)
* 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
Showing
7 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"velocy": "0.0.13" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |