summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api.js17
-rwxr-xr-xsrc/cli.js2
-rw-r--r--src/ircd.js16
-rw-r--r--src/web.js34
4 files changed, 65 insertions, 4 deletions
diff --git a/src/api.js b/src/api.js
index 99ba01c..17223cd 100644
--- a/src/api.js
+++ b/src/api.js
@@ -1,14 +1,25 @@
const { eq } = require("./utils.js");
+const ircd = require("./ircd.js");
+const web = require("./web.js");
-const main = async () => {
- if (process.argv.length !== 2) {
+const main = () => {
+ if (process.argv.length === 3 && process.argv[2] === "-V") {
console.log("papo 1970-01-01 0.1.0");
return;
}
+ if (process.argv[2] === "ircd") {
+ ircd.app(process.argv[3]);
+ return;
+ }
+
+ if (process.argv[2] === "web") {
+ web.app(process.argv[3]);
+ return;
+ }
+
console.log({
argv: process.argv,
- eq: eq({a: 1}, {a: 1}),
});
};
diff --git a/src/cli.js b/src/cli.js
index 2b486fe..1de3383 100755
--- a/src/cli.js
+++ b/src/cli.js
@@ -1,4 +1,4 @@
#!/usr/bin/env node
const { main } = require("papo");
-(async () => await main())();
+main();
diff --git a/src/ircd.js b/src/ircd.js
new file mode 100644
index 0000000..affc986
--- /dev/null
+++ b/src/ircd.js
@@ -0,0 +1,16 @@
+const net = require("node:net");
+
+const server = net.createServer(socket => {
+ socket.write("olar\r\n");
+ socket.pipe(socket);
+});
+
+const app = udsPath => {
+ server.listen(udsPath, () => {
+ console.log("I'm ircd.");
+ });
+};
+
+module.exports = {
+ app,
+};
diff --git a/src/web.js b/src/web.js
new file mode 100644
index 0000000..bfa1807
--- /dev/null
+++ b/src/web.js
@@ -0,0 +1,34 @@
+const http = require("node:http");
+
+const listProducts = () => {};
+const getProduct = () => {};
+
+const routes = {
+ GET: {
+ "/products": listProducts,
+ "/products/:id": getProduct,
+ },
+};
+
+const server = http.createServer((req, res) => {
+ const { headers ,url, method } = req;
+ console.log({
+ headers,
+ url,
+ method,
+ });
+ res.writeHead(200, {
+ "Content-Type": "text/plain",
+ });
+ res.end("Hello, web!\n");
+});
+
+const app = udsPath => {
+ server.listen(udsPath, () => {
+ console.log("I'm web.");
+ });
+};
+
+module.exports = {
+ app,
+};