completed 3.7

This commit is contained in:
counterweight 2025-06-01 18:51:05 +02:00
parent e35839318b
commit 7172413e79
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C

View file

@ -1,13 +1,6 @@
const express = require("express"); const express = require("express");
const app = express(); const app = express();
const morgan = require("morgan");
const requestLogger = (request, response, next) => {
console.log("Method:", request.method);
console.log("Path: ", request.path);
console.log("Body: ", request.body);
console.log("---");
next();
};
const unknownEndpoint = (request, response) => { const unknownEndpoint = (request, response) => {
response.status(404).send({ error: "unknown endpoint" }); response.status(404).send({ error: "unknown endpoint" });
@ -15,9 +8,7 @@ const unknownEndpoint = (request, response) => {
app.use(express.json()); app.use(express.json());
app.use(requestLogger); app.use(morgan("tiny"));
app.use(unknownEndpoint);
const persons = [ const persons = [
{ {
@ -128,6 +119,8 @@ app.get("/info", (request, response) => {
response.send(responseString); response.send(responseString);
}); });
app.use(unknownEndpoint);
const PORT = 3001; const PORT = 3001;
app.listen(PORT, () => { app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`); console.log(`Server running on port ${PORT}`);