summaryrefslogtreecommitdiff
path: root/src/hero.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/hero.mjs')
-rw-r--r--src/hero.mjs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/hero.mjs b/src/hero.mjs
index aa4a5a4..899e3fb 100644
--- a/src/hero.mjs
+++ b/src/hero.mjs
@@ -1,6 +1,7 @@
-import assert from "node:assert/strict";
-import crypto from "node:crypto";
-import http from "node:http";
+import assert from "node:assert/strict";
+import crypto from "node:crypto";
+import http from "node:http";
+import process from "node:process";
import * as u from "./utils.mjs";
@@ -121,7 +122,7 @@ export const handleRequest = async (table, method, url) => {
if (!handler) {
return {
status: 404,
- body: "Not Found",
+ body: "Not Found\n",
};
}
@@ -144,12 +145,14 @@ export const makeRequestListener = table => async (req, res) => {
res.end(response.body);
};
+export const log = o => console.error(JSON.stringify(o));
+
export const interceptorsFn = ({
uuidFn,
logger,
} = {
uuidFn: crypto.randomUUID,
- logger: u.log,
+ logger: log,
}) => ({
requestId: (req, next) => next({ ...req, id: uuidFn() }),
logged: async (req, next) => {
@@ -197,7 +200,7 @@ export const interceptorsFn = ({
});
return {
status: 500,
- body: "Internal Server Error",
+ body: "Internal Server Error\n",
};
}
},